codeigniter dynamic data template - codeigniter

I have this template view at view/include
<?php $this->load->view('include/header'); ?>
<?php $this->load->view($sidebar_column); ?>
<?php $this->load->view($result_column); ?>
<?php $this->load->view($footer_row); ?>
<?php $this->load->view('include/footer'); ?>
and i have the footer_row html at view/include
<div> this is footer row <?php echo $username ?></div>
then i call the footer_row in my controller
$data['footer_row'] = 'include/footer_row';
$this->load->view('include/template',$data);
My question, the footer_row is logged in user info and it appear in EVERY pages. With the above method I use, I have to call and retrieve the user info in every controller. How can i make it reusable so i don't need to repeat myself.

Reusability comes from making use of your constructors, and parent classes. Have a look at my previous answers:
Header and Footer in CodeIgniter
Constructor session validation for different functions

Instead of using this method why dont you use a template library which is easy to use. I would recommend Philsturgeons Template Library but there are some more you can use any that fits to your requirements.
Williams Concepts
http://williamsconcepts.com/ci/codeigniter/libraries/template/
Phil Sturgeons's
http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/
Most Simple
http://maestric.com/doc/php/codeigniter_template
And Finally Binpresses's
http://www.binpress.com/app/codeigniter-template-library/223

Related

Processwire Add css class to page

I there a possibility to add a classname to a page?
I can't figure out how to implement such feature or if it already exists.
I'm using Processwire 3.0.42.
Put something like this in your template where the body is:
<body class="<?php echo $page->template->name; ?>">
That will give your page body tag a class equal to page template name.
You can add a page title in the same way.
<body class="<?php echo $page->name; ?>">
Don't be worried about adding a class to every page. The overhead of doing this is negligible.
If you wish to add a different class you would need to add a field to your template and append it to the code above.
As always in ProcessWire, everything is under your control. Alternatives to #ivangretsky's perfectly good answer would include-
Simply include a conditional in your template file. (This doesn't scale well if you need to add other classes to other pages using the same template.)
<?php
$bodyClass = '';
if($page->id == 1021) $bodyClass = 'my-class';
?>
<body class="<?php echo $bodyClass; ?>">
NB Using $page->id is better than $page->name, for example, as the ID doesn't change while the name could.
You could also add a field to the page template definition. Add a field called something like 'Body Class'. Then use the content of that field in your template file.
<body class="<?php echo $page->body-class; ?>">
This will scale better than my other suggestion, and there are options in the ProcessWire backend to hide or partially hide the field during normal use if you don't want users messing with its value.
One 'gotcha' from the CSS spec to be aware of is that CSS identifiers, including class names and IDs cannot start with a digit, so you cannot just use $page->id.
There are lot of options and it depends on your needs and maybe imagination :-).
You can use page name, template name, page id, or maybe combination.
<body class="<?php echo $page->template->name; ?> page-id-<?php echo $page->id; ?>">
// Output
<body class="your-template-name page-id-1234">
This way you can target template, page, or both.
Or, as mentioned by #ivangretsky, you can add custom field to page. And again, you can combine this aproach with template name, etc.
It depends on your needs and what you want to achieve.
Notice:
Using $page->id is better than $page->name, as the ID doesn't change while the name could. #DaveP

add a CSS className to the custom option fields like radiobox and select

I want to group and show in different popup product custom options on frontend on product view page. So I want to give specific class to every product option from backend.
refernce from here
I have use this code but this is giving custom class options only for text-box type options, I want custom class to all type of product options.
Can anyone help?
Thank you.
Something I've used before (although I admit, does not look like a very neat way of doing it) is this in the catalog/product/view/options.phtml:
$search = 'product-custom-option';
$replace = 'product-custom-option form-control';
<?php foreach($_options as $_option): ?>
<?php echo str_replace($search, $replace, $this->getOptionHtml($_option)); ?>
<?php endforeach; ?>
Where the css class 'form-control' was the one I wanted to add.
[EDIT]
In that case, one solution I can think of is this:
Create a system.xml where you can add the CSS classes for the various option types
Create a helper class for retrieving the saved CSS classes
Edit the catalog/product/view/options/type/*.phtml files in your theme where you add the CSS classes by using the helper.
Would that work for you?

Can I have more than one success (onepage) page in magento

Can I have more than one success (onepage) page in magento. One for Cash on delivery and another for Online Bank transfer.
thanks in advance.....
Just modify the template file for checkout success page (checkout/success.phtml) to display what you want it to for each method used. You have access to the order object in the template and can do everything there. If you need additional functionality just extend the checkout success block and use the new functions in the template. Absolutely no need to create a new success page and if you did you would need to extend the checkout controller which could cause you problems down the line with upgrades etc.
<?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); ?>
<?php if ($order->getPayment()->getMethod() == "checkmo"): ?>
<p>Check or Money Order HTML</p>
<?php else if ($order->getPayment()->getMethod() == "bank_transfer"): ?>
<p>Bank Transfer HTML</p>
<?php endif; ?>
See this article by fontis for more information: http://www.fontis.com.au/blog/magento/customise-magento-checkout-success-page-based-payment-type

How do I manually theme Views in Drupal 7?

I am new to drupal and I am trying to figure out how to theme Views. I currently have a content type called Category with the following fields:Title, Image and Body. I created a view for the above mentioned content type so that I would list view of all the categories I have created.
To custom theme the view I created a folder called views in my theme folder, and created the following view files:
views-view-fields--plugin-categories.tpl.php
views-view--plugin-categories.tpl.php
views-view-unformatted--plugin-categories.tpl.php
This is what I currently have in my first file:
<div class="<?php print $classes; ?>">
<?php if ($rows): ?>
<div class="view-content">
<?php print $rows; ?>
</div>
<?php elseif ($empty): ?>
<div class="view-empty">
<?php print $empty; ?>
</div>
<?php endif; ?>
<?php if ($more): ?>
<?php print $more; ?>
<?php endif; ?>
</div><?php /* class view */ ?>
Instead of $rows, I tired to use print $field['image'] and print $field['body'] but this method does seem to work. Could you kindly advise on how I could theme the three fields, within categories, displayed using view?
You should name your template like this
views-view-fields--<machine-name-of-your-view>.tpl.php
So I'm assuming from the above that your view is called 'plugin-categories'. An easy way to check is to go to edit the view and look at the URL while you're on the edit page. It should have the format /admin/structure/views/view/YOUR-VIEW'S-MACHINE-NAME/edit, so you can get it from there.
Once you're sure it has the right name, clear your cache to make sure Drupal is picking up your new template. You just need the one above, not all three to modify the output of the three fields in question.
Once you've cleared cache, Drupal should be picking up the new template. You didn't mention exactly what isn't working, just that it's not working, so I wanted to cover the naming and caching, just in case. Now, to output particular fields in this view template, call them like this:
$fields['your-field-machine-name']
So $fields['body'] (I think you're missing an 's')
You should have nothing about $rows in this template! If you have anything about $rows, you haven't copied and pasted from the correct views template. Simply output the fields as you want them to appear in your view, in whatever order you want with the syntax above and put in whatever css classes, etc you want.
Let us know if that works!

joomla without a component on the main page

On the page I edit modules constitute the main page. Actually there is no need for any component out there.
I can't remove jdoc from the template because other part of the site requires it.
I wonder what is the best solution for the problem: for main page I need one template but for others another.
As far I have worked with joomla internals almost never with back-end so I guess my knowledge lack in this department.
Any hint how to achieve that?
You can do something in your template like:
<?php
$menu = JSite::getMenu();
if ($menu->getActive() != $menu->getDefault()) : ?>
<jdoc:include type="component" />
<?php endif; ?>
Which will disable the component position when on the default [home] page

Resources