As I'm having the same Header and Footer content accross all my pages, i'm using this code in the Views :
<?= $this->extend("layouts/default") ?> // this loads the header and footer
<?= $this->section("content") ?>
<?= $this->endSection() ?>`
But how could I do to display data from database in the footer, so that it's displayed on all pages (it's a list of blog categories)
I don't know how to proper this, as I'm willing to avoid running queries in the view files.
THank you!
Related
i have a view name admin_login.php.in that i included two files public_header.php and public_footer.php.
here is my
admin_login.php
<?php include('public_header.php'); ?>
<h1>Hello World</h1>
<?php include('public_footer.php'); ?>
i am getting both included files in my browser but h1 element is not loading in browser
Instead of including the header and footer file in your view, I'd suggest the recommended way.
In your Controller load your views like
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');
Create these partials in views directory and render with above statements.
I have installed Strategery InfiniteScroll. Which is working great for category listing page. Now i have a custom product page. I want to apply Strategery InfiniteScroll on my custom product page. How to do.?
My Page
<?php
$_productCollection=$this->getLoadedProductCollection();
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addFieldToFilter(array(array('attribute'=>'featured','eq'=>'1')));
$_productCollection->getSelect()->order('rand()');
$_productCollection->getSelect()->limit(20);
?>
//loop for products
</div>
</div>
Before you start, assure you have included .js file in your custom page.
if you see the ias.phtml template, it has some container defined.
You need to add the same code for your custom page.
For documentation of infinite ajax scroll, read this
I want to handle the product overivew separataly to the product detail view. I want to add additional text right behind the price in the product deatil view.
I tried to edit the view.phtml in path app/design/frontend/mytheme/default/template/catalog/product/view.phtml, refreshed caches and so on, but nothing changed.
In catalog.xml view.phtml will be load. So its seems correct.
But even when I try to echo "test" it doesnt show anything.
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<div class="std"><h2><?php echo $this->__('Details:') ?></h2>
</div>
</div>
<?php echo "test";
endif;?>
Do you have any hint?
Regards
Matt
You should enable template path hints in the backend to check which template file is used to render product page. Make sure that the cache is also disabled.
Joomla 3.2.1
I have a category with 26 subcategories.
In my template I want to add some code that shows 2 modules if the page is from one of the 27 categories.
I tried this code
<?php if (JRequest::getVar('view')=='categories' && JRequest::getVar('id')==30) { ?>
<div id="menu_abc">
<jdoc:include type="modules" name="menu_abc" />
</div><!-- end menu_abc -->
<?php } ?>
But that's only one category and it didn't work. The modules didn't show in that one category page (a category list page and an article in one of the subcategories).
I want the modules to show automatic only on all article pages, category list pages en category blog pages of this 27 categories.
Does someone know how to do this? It's only a small piece of code so I prefer not to use another template and cameleon or something if that's possible.
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!