$js in select dropdown in codeigniter - codeigniter

I have a js in a folder js. I call the file in the header.
I have the next code in my view:
<?php echo form_dropdown('mydropdown',$options) ?>
I need to pass the paramether $js, could you help me with the syntax?
$js = 'id="shirts" onChange="display(this,\'id1\',\'id2\');"';
<?php echo form_dropdown('mydropdown',$options, $js) ?>
When I see the source code of my dropdown I can't see the id="shirts", then I believe that the function javascript is not recognized.
What's my error. My codeigniter version is 2.0.
Thanks.

javascript should be the fourth parameter to this call. So add a null parameter in the third (which is for the selected value of the dropdown):
<?php echo form_dropdown('mydropdown',$options, null, $js) ?>
http://ellislab.com/codeigniter/user_guide/helpers/form_helper.html

Related

Remove the HTML from renderField output

Is there any way I could strip html out of this?
<?php echo $this->form->renderField('monday'); ?>
In the back end theres a selection where you pick options that show up in a schedule but they are showing up as html and I need them to show up as plain text for the selection.
you can use php strip_tags function
<?php echo strip_tags($this->form->renderField('monday')); ?>
http://php.net/manual/en/function.strip-tags.php.
If you wanna keep some tags, look at the section allowable_tags
You should know that select and option are also html tags and will be removed if you use strip_tags. So you can allow those tags. You can modify your code like this
<?php $field = strip_tags(($this->form->renderField('monday')),'<select><option>');
echo $field;
?>

Changing error delimiter to empty in codeigniter

i want to change the form error wrapper. I don't want any wrapper no div no <p> i have used this code <?php echo form_error('inv_data_val','<div>','</div>'); ?> it do adds the div but when i used <?php echo form_error('inv_data_val','',''); ?> it still shows p
http://www.codeigniter.com/userguide3/libraries/form_validation.html#changing-the-error-delimiters
$this->form_validation->set_error_delimiters('', '');
In your controller.

I want change page heading position

In Joomla Page heading showing inside of an article I want to change the position of page heading, is it possible to customize page heading position?
I had included following code in template/protostar/index.php
<?php if ($this->params->get('show_page_heading', 1)) : ?>
<div class="page-header">
<h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
</div>
<?php endif;
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && $this->item->paginationrelative)
{
echo $this->item->pagination;
}
?>
What you can do:
Just update one of the css files in the correct template to display the header correctly. If the header should only be reformatted on some pages and not all then you should be using different templates.
What you should do:
Otherwise (if you want to change the php instead) you can override the components/com_content/views/article/default.php using the standard joomla override method.
You can do both the above if necessary.
You should not need to override the index.php of your template in order to do this. However if you really want to i would use the code
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
echo $article->get("title");
}
Sorry if you want more you need to give more :)
PS. I am on joomla 2.5 but i know that for joomla 3 it is more or less the same thing.
Sources: http://forum.joomla.org/viewtopic.php?t=525350
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

CodeIgniter adjusting url when passing parameters to controler

Ok i have records from database listed in view file, so u can see i wanna pass values to controler via href by update/grab function controler
echo $this->pagination->create_links();
br().br();
foreach ($query->result() as $q): ?>
<?php echo $q->info . br()?>
<?php endforeach; ?>
it works for first page in my pagination, when i am on some other page when i clicked on on record, instead passing parametars to controler when i clicked in keep adding url for example http://localhost/z/records/users/update/grab/3/update/grab/1/update/grab/1/update/grab/1/trtr
So error is when i have in url, when i am on second page in pagination
http://localhost/z/records/users/2
works only when i am on first page
http://localhost/z/records
is there a way to solve this proble. Will it works if i some how adjust routes??? Need help, please help me its very important
Try changing your link to an absolute URL:
<a href="/z/update/grab/<?php echo $q->id;?>/<?php echo $q->info; ?>">
Or adding a correct relative URL base to the header of your pages:
<base href="/z/" />
Codeigniter routes allow you to do this:
$route['post/(:any)/comment/(:any)'] = "posts/comments/$1/$2";
Then in the controller, the function inside my posts controller would work like this:
public function comments($one, $two) {
echo $one."-".$two;
}
so if you hit the url "/post/111/comment/222" the output would be
111-222

Magento - adding a widget instance to a template file

I know that you can call a cms block directly from a template file using the following:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('footer_links')->toHtml() ?>
Is there some way to do this with widget instances?
In your template:
<?php
$filter = Mage::getModel('widget/template_filter');
echo $filter->filter('{{widget type="cms/widget_page_link" template="cms/widget/link/link_block.phtml" page_id="2"}}');
?>
Andrew missed toHtml() function at the end:
<?php echo $this->getLayout()->createBlock('cms/widget_page_link')->setTemplate('cms/widget/link/link_block.phtml')->setPageId(2)->toHtml(); ?>
To know the correct parameters "type", "template" and more, you can use the "Insert widget" button on the graphical editor in a block/page template, then you click the show/hide editor and you get the code
The answer above may work, but the same thing can be achieved by loading the widget as you would a static block and passing in the custom parameters using the magic setters like this:
<?php echo $this->getLayout()->createBlock('cms/widget_page_link')->setTemplate('cms/widget/link/link_block.phtml')->setPageId(2); ?>

Resources