Changing error delimiter to empty in codeigniter - 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.

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;
?>

show welcome message only on index.php [CI]

I make custom welcome message in codeigniter script, but i want show only on index.php
I have
<div class="welcome">
<?php echo getConfigSetting('config_welcome') ?>
</div>
This message show in header,on all page. I want show only on homepage (index.php)
I already tried this code but give me a blank page
<?php if( $this->uri->segment(1) == 'home' || $this->uri->segment(1) = '' ): ?>
Affordable Business Websites Done Fast…
"Just find a website you like and we will customize it to your business needs, easy as 123!"
Start Search
</div>
</div>
Any sugestion?
Thank you
you could try to use the CI helper URL and grab the first segment of the url to check whta page we are on.
example:
<?php if( $this->uri->segment(1) == 'home' || $this->uri->segment(1) = '' ): ?>
<div class="welcome">
<?php echo getConfigSetting('config_welcome') ?>
</div>
<?php endIf; ?>
of course you would want to change the "home" to the name of your homepage name you see in the url, or the default controller/method name.
You will also want to make sure you autoload the url_helper in the config/autoload.

Magento shows attribute if value is left blank

I have a drop down magento attribute for warranty_labour. I'm pulling in the attribute using my themes product/view.phtml and then attaching an icon to show what warranty you get.
Ive used this code which successfully works:
<?php $warranty=$_product->getAttributeText('warranty_labour'); echo '<img style="padding-top: 10px;" src="/images/warrantylabour/'.str_replace(' ', '_',$warranty).'.png" alt="'.$warranty.'">'; ?>
The problem I find when a product doesn't have a warranty attribute set (left blank on the backend) I still get the code inserted on to the product source code on the frontend like this:
<img style="pad`ding-top: 10px;" src="/images/warrantylabour/.png" alt="">`
Is there a way I can stop this happening when a value isn't set in the attribute?
Don't forget logic! :-) Just test that $warranty has a value Using typical Magento template conventions:
<?php if($warranty=$_product->getAttributeText('warranty_labour')): ?>
<?php echo sprintf('<img style="padding-top: 10px;" src="/images/warrantylabour/%s.png" alt="%s"/>', str_replace(' ', '_',$warranty),$warranty) ?>
<?php endif; ?>
This kind of syntax might justify encapsulating this logic and string building into a helper method, I think.

How to theme views fields in Drupal 7 correctly

I need to theme views in Drupal 7. There is a content type 'Book' and I need to list 5 books and theme them in special manner(preview image, title and author).
When I override views-view-field.tpl.php and print raw SQL result, I see that all fields are displayed. This code
echo "<pre>";
print_r($row);
echo "</pre>";
gives
[entity] => stdClass Object
(
[title] => ...
....
[nid] => 34
...
[body] => Array
...
But I don't want pass [body] from database to php side, because it can be huge and cause a performance issue. I haven't selected [body] in view settings.
Is there a way to pass only certain fields to views-view-field.tpl.php?
Thanks in advance.
The variables available are written in the documentation inside the sites/all/modules/views/theme folder's files.
Usually, the variable you need to look at and modify on a views-view-fields.tpl.php template is $fields
I use the devel module (http://drupal.org/project/devel) to view the variables available:
<?php
//after enabling the devel module...
dpm($fields);
// This will print a Kuomo display on the page with the array's vars
?>
Generally, on a view of nodes,
<?php print $fields['title']->content; ?>
will print the node title. For fields, try
<?php print $fields['field_FIELDNAME']->content; ?>
If you have the memory, you can capture ALL vars available on the template in the Kuomo with
<?php dpm(get_defined_vars()); ?>
Make sure you clear your cache before you try to view the vars.
If what you want to do is theme a certain field you can create a template for that specific field like this one: views-view-field--field-nameofmyfield.tpl.php place it in your theme folder and rescan the templates in the Theme:information part of the View configuration.
For that to work you have to have the field added to Fields in the View.
To sort through your information in a theme use this:
<?php dpm ($rows); ?> // View all the information in the view
<?php foreach ($rows as $row_count => $row): ?>
<?php print $row['title'];
<?php print $row['nid'];
<?php endforeach; ?>
If you want to change of theme of view then Change views-view-fields.tpl.php like this:
<div class="pagecontent">
<div class="colleft">
<?php if($fields['field_file']->content){ ?><div class="views-field-file"><?php print $fields['field_file']->content; ?></div><?php } ?>
</div>
<div class="colright">
<div class="views-field-title"><?php print $fields['title']->content; ?></div>
<div class="views-field-body"><?php print $fields['body']->content; ?></div>
<div class="views-field-view-node"><?php print $fields['view_node']->content; ?></div>
</div>
</div>

$js in select dropdown in 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

Resources