Is it possible to add two or more views in one layout in cakephp 2.x?
What you might need are elements: http://book.cakephp.org/2.0/en/views.html#elements
you can put all info data in one element and then include it wherever you want.
view:
<div class="info">
<h2><?php echo __('Info'); ?></h2>
<?php echo $this->Element('info'); ?>
</div>
view/elements/info.ctp:
<?php echo 'Hello world'; ?>
Related
How to disable particular layout(example:menus.phtml) for particular pages in controller in ZF2?? In the below example menus.phtml should be disable for specific pages. Remaining pages must contain menus.phtml like header and footer.
<div>
header.phtml
</div>
<div>
menus.phtml
</div>
<div>
<?php echo $this->content; ?>
</div>
<div>
footer.phtml
</div>
There are various aproaches to this. Also modules.zendframework has quite a few modules here that may help you out.
If you are still keen on writing that yourself you could add variables to your layout within your controllers like so:
<?php
//YourController.php
public function someAction()
{
...
$this->layout()->footer = 'default';
...
}
//layout.phtml
<?php if ($this->footer === 'default') : ?>
//show the footer
<?php endif; ?>
Doing this is pretty inefficient though. Just imagine you'd need to do this to every action in all the controllers... I sure would not like to do that.
Now zf2 has a service and event layer that could help us out quite a bit here. This is a pretty nice read and introduction to it. You'd just write a service and trigger a event on your controllers/routes/whatever. Now you would also probably like to configure what is shown and what is hidden right? Thats pretty easy, too. Just write yourself a config file and merge it with the global.config like so:
<?php
//CustomModule/module.php
public function getConfig() {
$config = array();
$configFiles = array(
include __DIR__ . '/config/module.config.php',
include __DIR__ . '/config/module.customconfig.php',
);
foreach ($configFiles as $file) {
$config = \Zend\Stdlib\ArrayUtils::merge($config, $file);
}
return $config;
}
Source: Where to put custom settings in Zend Framework 2?
First, get the controller or action name:
$controllerName =$this->params('controller');
$actionName = $this->params('action');
then in your layout/view script add a simple logic.
<?php if ($actionName != 'action that you want to disable the layout/menu'): ?>
echo $this->render('menus.phtml');
<?php endif; ?>
I have a hierarchical custom post type. It has 6 pages, and each page has 3 child pages.
When viewing one of the 6 pages, I need to display content (a title and excerpt) from each of its 3 child/descendent pages.
Here is my current loop:
<?php if(have_posts()):?>
<?php query_posts('&post_type=how-we-do-it&post_parent=0');?>
<?php while(have_posts()):the_post();?>
<?php $color = get_post_meta( get_the_ID(), 'pointb_how-we-do-it-color', true ); ?>
<div class="section">
<div class="title">
<h1 style="background:<?php echo $color;?> !important;">
<?php the_title();?>
</h1>
</div>
<div class="content">
<div class="how-<?php the_slug();?>">the summary here. and here is child content:
<div class="child">child content should be here.</div>
</div>
</div>
</div>
<?php endwhile;?>
<?php wp_reset_query(); ?>
<?php endif;?>
I have tried numerous different approaches to try and accomplish what I need, but none of them work within the custom post type. Here are some of the various methods I have tried:
I tried the suggested code on this page: http://wordpress.org/support/topic/display-child-pages-title-amp-content-on-parent-page
I also tried the following code:
$pageChildren = get_pages('child_of='.$post->ID');
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<h2>'. $pageChild->post_title.'</h2>
';
if ($pageChild->post_excerpt){
echo ''.$pageChild->post_excerpt.'
';
}
}
}
I've tried a number of other methods that I didn't bother saving, so I can't show them.
I'm at the point where I am getting frustrated with this and thought I'd throw it out here to get some fresh perspectives.
The issue with your first sample is that you call if(have_posts()) before you reconstruct the query.
The second sample has a dangling ' after $post->ID.
Try this:
$pageChildren = get_posts( 'post_type=how-we-do-it&post_parent='.$post->ID );
Based on some comments from MarZab above, I got thinking about the post ID.
I made the following tweak to the block of code I originally posted above, and now it works perfectly:
$pageChildren = get_pages('child_of='.$post->ID');
Is now:
$post_id = get_the_ID();
$pageChildren = get_posts( 'post_type=how-we-do-it&echo=0&post_parent='.$post_id );
Please help...anyone
I have a problem with hiding some configurable attributes:
These are my configurable attributes at the back-end:
Shape/Type
Grit & Colour
Shank
Items pack
Diameter
Supplier
My client wants to hide the "Manufacturer" attribute on the front-end
but wants to import the supplier at the back-end.
Please see the website I am working:
http://ridental.com.au/newsite/polishers.html/
I managed to hide it from front-end by just adding some if statement
like this: in the app\design\frontend\default\MYTEMPLATE\template\catalog\product\view\type\options\configurable.phtml
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl class="outer">
<dl class="inner">
<?php foreach($_attributes as $_attribute): ?>
<?php $attCode = $_attribute->getProductAttribute()->getFrontend()->getAttribute()->getAttributeCode(); ?>
<?php if($attCode != "manufacturer"):?>
<div class="dtdd-wrapper<?php if ($_attribute->decoratedIsLast){echo " last";}?>">
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
</div>
<?php endif; ?>
<?php endforeach; ?>
</dl>
</dl>
<script type="text/javascript">
[b]var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);[/b]
</script>
The Manufacturer will not be displayed on the front-end.
But when I click Add to Cart button I got the error:
Please specify the product's option(s).
I noticed that in:
var spConfig = new Product.Config(<?php echo $this->getJsonConfig()
It is still referring to the attribute "supplier" and waiting for the user response to choose Manufacturer in the drop down.
that's why I get the error: Please specify the product's option(s).
My question:
Is it possible to filter the function getJsonConfig()?
let say not include the:
if ($attributecode != 'manufacturer'){
do some stuff.....
}
I copied a local version of this function and now found in: app\code\local\Mage\Catalog\Block\Product\View\Type\Configurable.php
Please help...if anyone accomplished this kind of problem.
I tried extending getJsonConfig() to filter some attribute like "supplier" but to no avail.
Am I doing the right thing?
Chances are, from what you are describing, you should remake the configurable product without using the "Supplier" attribute.
When you make a configurable product, the first screen that allows you to mark attributes with check boxes is meant to define what the configurable product will be filtering, the attributes will still be attached to the product information.
I'm attempting to put a bit of style on a specific set of exposed filters on a view that I have created.
The view is called user_search and so I have created views-exposed-form--user-search.tpl.php and that didn't work (all it did was remove the exposed filters but still displayed the view). views-exposed-form--user-search--page.tpl.php also got the same results.
Even if it did work, I still don't know what to put there to get the form to show up, just so that I can add styles or container divs.
print drupal_render($form); did not work.
I found a solution after a lot of digging.
First, you have to find the views-exposed-form.tpl.php file which should be located in sites/all/modules/views/theme/ folder. We're using the acquia stack so it was located in the vendor/ folder.
Copy this to themes/YOUR-THEME/ folder and rename it to views-exposed-form--your-view-name.tpl.php
If you only want to effect a specific display of your view name it to views-exposed-form--your-view-name--display.tpl.php
You can then use the existing framework to edit it as you see fit. Here's an example.
<?php
// $Id: views-exposed-form.tpl.php,v 1.4.4.1 2009/11/18 20:37:58 merlinofchaos Exp $
/**
* #file views-exposed-form.tpl.php
*
* This template handles the layout of the views exposed filter form.
*
* Variables available:
* - $widgets: An array of exposed form widgets. Each widget contains:
* - $widget->label: The visible label to print. May be optional.
* - $widget->operator: The operator for the widget. May be optional.
* - $widget->widget: The widget itself.
* - $button: The submit button for the form.
*
* #ingroup views_templates
*/
?>
<?php if (!empty($q)): ?>
<?php
// This ensures that, if clean URLs are off, the 'q' is added first so that
// it shows up first in the URL.
print $q;
?>
<?php endif; ?>
<div class="views-exposed-form">
<div class="views-exposed-widgets clear-block">
<?php foreach($widgets as $id => $widget): ?>
<div class="views-exposed-widget">
<?php if (!empty($widget->label)): ?>
<label for="<?php print $widget->id; ?>">
<?php print $widget->label; ?>
</label>
<?php endif; ?>
<?php if (!empty($widget->operator)): ?>
<div class="views-operator">
<?php print $widget->operator; ?>
</div>
<?php endif; ?>
<div class="views-widget">
<?php print $widget->widget; ?>
</div>
</div>
<?php endforeach; ?>
<div class="views-exposed-widget">
<?php print $button ?>
</div>
</div>
</div>
When in doubt about how to theme a part of a page, install the Theme Developer module. It will allow you to see what theme file or function is currently outputting a specific area of the page, as well as what files or functions can be used to override it. See the screencast for more detailed information.
I want to display subcategories under artist category in one layout and design and other categories in another layout and design in Magento 1.4.1.1.
In the web admin, under Manage Categories, select the categories you want to be different and navigate to the Custom Design tab. You can enter layout updates or select alternative skin/themes.
The best way to do this is to use static blocks.
1) Create phtml file in /template/catalog/navigation
<?php $_categories = $this->getCurrentChildCategories(); ?>
<ul>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li>
<?php echo $this->htmlEscape($_category->getName()) ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
2) Create static block "Subcategories"
{{block type="catalog/navigation" template="catalog/navigation/subcategory.phtml"}}
3) Assign static block for needed category ("Display Settings" tab -> Display Mode = Static block only and select CMS Block "Subcategories")