FancyBox like in gii module - php

I want a FancyBox like that one in the gii module code generator. I have downloaded the EFancyBox extension and made it run. The first time when i press the link the fancybox is properly displayed and i close it, but when i try the second time a blank window appears with no content. Here is the code:
<?php echo CHtml::link($url,"#data", array('id'=>'iframe')); ?>
<div style="display:none">
<div id="data"><iframe src="<?php echo $url; ?>"
frameborder=0 width=1024 height=768 scrolling=yes></iframe></div> </div>
<?php $this->widget('application.extensions.fancybox.EFancyBox',
array( 'target'=>'a#iframe', 'config'=>array( 'scrolling' => 'no', 'titleShow' => true, ), ) ); ?>
</div>
I have found the solution:
<?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#iframe', 'config'=>array( 'scrolling' => 'no', 'titleShow' => true, 'onClosed'=>"js:function(){parent.location.reload(true);}" ), ) ); ?>

It seems ok to me, because when you reload the data you need to tell to the fancybox the new dom elements, when you reload you tell the new elements, its ok like that.

<?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#iframe', 'config'=>array( 'scrolling' => 'no', 'titleShow' => true, 'onClosed'=>"js:function(){parent.location.reload(true);}" ), ) ); ?>

Related

fread / fgets - How do I make php read links

I'm trying to make a php site read from a text file by using this:
<html>
<head>
<title>This is a test!</title>
</head>
<body>
<?php
$f = fopen("testfile.txt", "r");
// Read line by line until end of file
while(!feof($f)) {
echo fgets($f) . "<br />";
}
fclose($f);
?>
</body>
</html>
-and it works!
Next step is to make the php site read text with links inside.
This is the text in the text file within a link, please press this link www.stackoverflow.com and more text to come after the link. Linktext like "THIS IS A LINK" is also needed.
Hope you understand what I want:)
How do I do something like this?
From reading your: "I want seperate text files for the different text sections on the site."
Have you considered using a separate php file "setting.php" and inside making a multidimensional array with all the things you need?
<?php
$settings = array(
'header_text' => array(
'text' => 'This is my header text and it containts a link click here',
'color' => '#000000',
'font-size' => '12px'
),
'footer_text' => array(
'text' => 'Copyright © Terms and Conditions',
'color' => '#000000',
'font-size' => '12px'
),
);
?>
and if you need to go a step deeper and do it PER page:
<?php
$settings = array(
'index.php' => array(
'header_text' => array(
'text' => 'This is my header text and it containts a link click here',
'color' => '#000000',
'font-size' => '12px'
),
'footer_text' => array(
'text' => 'Copyright © Terms and Conditions',
'color' => '#000000',
'font-size' => '12px'
)
),
'about.php' => array(
'header_text' => array(
'text' => 'This is my header text and it\'s only for the about page and it containts a link click here',
'color' => '#000000',
'font-size' => '12px'
),
'footer_text' => array(
'text' => 'Copyright © Terms and Conditions and go to the main index page',
'color' => '#000000',
'font-size' => '12px'
)
),
);
?>
you can then include this file in your main script
include('settings.php');
and then call upon the array and such, all you do it edit the php file, and any changes would update.
This way you can manually edit any details you want!
Example:
<?php include('settings.php'); $curr_page = basename($_SERVER['PHP_SELF']); ?>
<div style="color: <?php echo $settings['header_text']['color']?>"><?php echo $settings[$curr_page]['header_text']['text']?></div>
<div style="color: <?php echo $settings[$curr_page]['header_text']['color']?>"><?php echo $settings[$curr_page]['header_text']['text']?></div>
Thanks for your great answer - it was easy to understand.
I need to make my php site read from a text file because it is my boss who needs to change text on the site, and I don't want him to delete any of the coding.
So, is there any way to make the php site read from a text file?
This is a text 1 (must be read from document 1)
This is another text (must be read from document 2)
This is another text section on the php and THESE WORDS shuld be a hyperlink in the middle of the sentence.
etc...
Thanks again!

Custom CLinkPager Yii Framework

basically:
<?php $this->widget('CLinkPager', array(
'pages' => $pages,
)) ?>
when render: 'Go to page:...'
i want to push 'Go to page: ' to my element (ext: Go to page), somebody can help me?
If I am not wrong you might want to access the header property of CLinker page which defaults to Go to page
<?php $this->widget('CLinkPager', array(
'pages' => $pages,
'header'=> 'whatever you want'
)) ?>

how to pass a php variabe to yiibooster modal window via link

I want to pass a php variable to modal window , what i am doing is opening a modal window using this link , but i want to pass a variable to this link and get same variable in modal window , i try to to do this to append a text in some div but it return html that i am unable to get in query
echo CHtml::link(
'Set Recipe', '', array(
'class' => 'testclass',
'id' => $finalDate,
'data-toggle' => 'modal',
'data-target' => '#myModal',
'fahadVar' => $finalDate
));
and when i click this button i got modal window how to get variable set in button
Here is simple modal code of yiibooster
<div class="modal-body">
<p>One fine body...</p>
</div>
<div class="modal-footer">
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'type' => 'primary',
'label' => 'Save changes',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Close',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
</div>
<?php $this->endWidget(); ?>
thanks in advance
You should create a Widget.
Note: I copied below from another post. It works like charm.
First Create a new widget. Let say the name is CategoryWidget. Put this widget under components directory protected/components.
class CategoryWidget extends CWidget {
public function run() {
$models = Category::model()->findAll();
$this->render('category', array(
'models'=>$models
));
}
}
Then create a view for this widget. The file name is category.php. Put it under protected/components/views
category.php
<?php if($models != null): ?>
<ul>
<?php foreach($models as $model): ?>
<li><?php echo $model->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Then call this widget from your main layout.
main.php
// your code ...
<?php $this->widget('CategoryWidget') ?>

WYSIWYG editor generated by Wp_editor is disabled

Initial issue:
My client wanted an custom HTML rendering sidebar widget for their wordpress site. I created a simple one that allows them to choose the color (class switching) and gives them a textarea to put their HTML into. Now they have requested a basic WYSIWYG interface attached to it (CKEditor or TinyMCE) but I dont know how to add it to the textarea inside the widget code. Does anyone know how, have an example, or a place to see how it can work? Thanks!
EDIT (After use of wp_editor):
So I have my code to this point but the editor is disabled and not able to be used. Any ideas why?
<fieldset>
<label>Enter your HTML</label>
<?php
$settings = array(
'wpautop' => true,
'media_buttons' => false,
'tinymce' => array(
'theme_advanced_buttons1' => ',bold,italic,underline,|,link,unlink',
),
'quicktags' => false
);
$bodyID = $this->get_field_id('body');
$content = '';
wp_editor($content, $bodyID, $settings );
?>
</fieldset>
Use wp_editor function, your code will look something like this:
http://codex.wordpress.org/Function_Reference/wp_editor
<fieldset>
<label> Your label for the text area </label>
<?php
$settings = array(
'wpautop' => true,
'media_buttons' => false,
'tinymce' => array(
'theme_advanced_buttons1' => 'formatselect,|,bold,italic,underline,|,' .
'bullist,blockquote,|,justifyleft,justifycenter' .
',justifyright,justifyfull,|,link,unlink,|' .
',spellchecker,wp_fullscreen,wp_adv ',
),
'quicktags' => false
);
wp_editor('initial content', 'id of textarea', $settings );
?>
</fieldset>
Note that if you want to put the content in the WP database from front end you should use in addition wp_insert_post function and a POST varible as a link.

CakePHP - how to use Helpers to make an image link with target="_blank"

This seems like it should be simple, but I'm new to CakePHP. Maybe it's just something I should write in good ole HTML, but - was hoping to find out how do to this with CakePHP's HTML helper.
I just want an image link that has target="_blank".
This is what I tried:
<?php echo $this->Html->link($this->Html->image('tmp/728x90.jpg',
array('alt'=>'advertisement', 'height'=>'90',
'width'=>'728')),'http://www.google.com', array('target'=>'_blank')); ?>
(all in one line - just broke up for ease of viewing)
But when I do this, I get this:
<img src="/img/tmp/728x90.jpg" alt="advertisement" height="90" width="728" />
Any help is greatly appreciated.
Answer (thanks deceze)
<?php
$image = $this->Html->image(
'tmp/300x600.jpg',
array(
'alt'=>'advertisement',
'height'=>'600',
'width'=>'300'
)
);
echo $this->Html->link(
$image,
'http://www.google.com',
array(
'target'=>'_blank',
'escape' => false
)
); ?>
<?php echo $this->Html->link($this->Html->image('fb2.jpg',array('alt'=>'facebook', 'height'=>'90','width'=>'728')),'http://www.facebook.com', array('target'=>'_blank','escape'=>false)); ?>
You need to tell HtmlHelper::link not to HTML escape the input.
This is all very well documented in the manual.
The exact code will be like this
<?php
echo $this->Html->link(
$this->Html->image('tmp/728x90.jpg',
array(
'alt'=>'advertisement', 'height'=>'90',
'width'=>'728')
),
'http://www.google.com',
array(
'target'=>'_blank',
'escape'=>false)
);
?>
You need to use the Html->image . Check it out:
http://book.cakephp.org/view/1441/image
Like mentioned in the Cook Book, you can use the 'url' option of the image method:
echo $this->Html->image("recipes/6.jpg", array(
'alt' => "Brownies",
'url' => array('controller' => 'recipes', 'action' => 'view', 6)
));
echo $html->link("more",array('controller' => 'users', 'action' => 'index/welcome'), array('style'=>'_blank'), false, false);?> image('more-arrow.png', array('alt' => 'more','height'=>'11','width'=>'17'))?>

Categories