Magento - including CMS content in templates - magento

I have created a new layout templates in apps/frontend/default/my_theme/template/page and named it home-page.phtml and I have added my own html to this template.
The layout has 3 sections, that are promotional images and I'd like to include these on my homepage.
I have included the code:
echo $this->getChildHtml('right');
and this seems to display some other images and a poll.
What I'd really like to so, is to include some kind of centent that can be managed in the CMS instead of the content that is outputted when using the above code.
Is this possible and how do I do it?
Kind regards

Simple:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('cms_block_id')->toHtml() ?>

Related

Restricting Slideshow CK to certain pages within Joomla

I am trying to show Slideshow CK only on the homepage of my Joomla based site. I have gone into the 'assignment' section of the module and restricted it to 'Home' menu item and said 'no' to include on child items. This works fine. I only see the slideshow on my homepage. However, I have created a link to an article on one of my other menus. When that article is displayed, it shows the slideshow. I want to suppress it when it jumps to that link. I have been playing with various options but without much joy. I would appreciate it if somebody can clarify the control mechanism for selectively displaying the slideshow.
I have found a method of overcoming the problem but someone may suggest a better approach. I specifically went and excluded certain selected articles in the assignments. I had tried to exclude a 'hidden' category but that did not work for me. The downside of my approach is that every time I introduce a new article I have to exclude it.
If I understand correctly you are creating articles without menu items. Without a menu item you won't be able to control the module assignment so easily.
If you're comfortable editing your template an lternative approach would be to amend the template and load the module.
Locate the index.php file of your template. You should be able to do this via the template manager.
Create a custom module position e.g. slideshow-ck and assign the slideshow module only to the homepage.
Then in the template you would need to add some PHP as follows:
<?php
$menu = $app->getMenu();
$active = $menu->getActive();
if ($menu->getActive() == $menu->getDefault('en-GB')) && $this->countModules('slideshow-ck') ?>
<jdoc:include type="modules" name="slideshow-ck" style="html5" />
<?php endif; ?>
Basically what that does is only load the module position if it's assigned to the menu item AND the user is currently viewing the homepage.
https://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

Magento widget rendering in non-CMS content

Is there a simple way to hook into the Magento widget rendering feature on something other than CMS block or page?
I have a tooltips extension to display tooltips on custom options. There will be lots of products all with the same options and all needing the same tooltip text. While the tooltip extension we're using provides a means to declare snippets that can then be used on products, the snippets are added to individual products at setup time rather than referencing the single snippet instance. Thus if the tooltip content needs to change across all products we have to edit the snippet and then reapply the modified snippet to all products.
It would be preferable to be able refernce the snippet direct rather than just using it at product setup, but that's not how it works. So an alternative would be to include a static block in the tooltip description and reference the single description instance with our theme's already provided widget feature that works for on CMS pages e.g. {{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="xx"}}, where xx is the block created for this tooltip.
This needs the tooltip HTML description parsed through whatever it is in Magento that parses content HTML and processes any widget directives it contains.
I tried the following, where $tipstext is the tooltips HTML containing the widget directive, but no go. Didn't think it would be that simple!
Mage_Cms_Model_Template_Filter::filter($tipstext);
Anyhone have any idea if/how this could be achieved easily?
The class Mage_Cms_Model_Template_Filter does not have a widgetDirective method so it does not know how to parse {{widget}} short codes. Try instead Mage_Widget_Model_Template_Filter:
Mage::getSingleton('widget/template_filter')->filter($text);
This should work
<?php
$filter = new Mage_Widget_Model_Template_Filter();
$_widget = $filter->filter('{{widget type="cms/widget_page_link" template="cms/widget/link/link_block.phtml" page_id="2"}}');
echo $_widget;
?>

How do I place Magento theme blocks?

I am using two plugins, easycatalogimg and bannerslider.
For sanity purpose, I am using the default Magento theme, I am just trying to learn the template engine.
When I enable easycatalogimg, it appears above the bannerslider on the homepage. I am using the following code to call bannerslider.phtml, within CMS -> Homepage.
{{block type='bannerslider/bannerslider' template='bannerslider/bannerslider.phtml'}}
I would like to call the bannerslider, then easycatalogimg. Problem is, I cannot determine what block type easycatalogimg is. If I could, I would just turn off the homepage display, and then place the block beneath that. When I turn on the setting to make easycatalogimg appear on the homepage, it inserts itself above the rest of the page content.
Are there files I can open to determine what block type easycatalogimg is? Then I could do this code, right under the bannerslider.
{{block type='foo/bar' template='default/default/easycatalogimg.home.phtml'}}
Right now, the easycatalogimg appears on the homepage.
IN AN IDEAL WORLD, the solution here would be that I would edit a page like...
frontend/base/default/template/cms/content_heading.phtml
...within that page, call out the bannerslider.phtml and easycatalogimg/homepage.phtml.
Open the template file of the block you want to know the type. If it's a default Magento template, it will generally have the Block_Class name at the top. If it doesn't, run:
<?php echo get_class($this) ?>
That will give you the Block_Class name which then gets translated into Magento's calling convention, such as:
<?php $block = $this->getLayout()->getBlock('core/template') ?>
Where 'core/template' gets translated into Mage_Core_Block_Template

How to call a custom php file on magento product page

if getChildHtml('product_type_data') ?> maps directly to catalog/product/view/type/simple.phtml by default, how do I map to my own file? If I wanted to create a file that would produce a small image to place on the product page, right under "availability" how would I tell magento to map to where I have put the file? From what I understand getChildHtml('product_type_data') ?> defaults to the file path: catalog/product/view/type/simple.phtml so how can I customize the magento defaults and tell it to map to my custom files i've created?
Could I do something like getChildHtml('etc/etc/my-file.phtml') ?>
Essentially, what I am trying to do is add a small image under "availability" of my site (ex: http://climbhigh.com/climbing/climbing-ropes/petzl-dragonfly-rope-8-2mm.html) that says free shipping. Just trying to find the best way to do it.
I hope I have explained this well enough, if not, please let me know and I will try to explain more. Any help or guidance would be awesome. Thanks.
The code getChildHtml('product_type_data') doesn't always map directly to the template file catalog/product/view/type/simple.phtml. It only maps to that file if the layout handle PRODUCT_TYPE_simple is loaded, i.e. if the current product is a simple product. In order to change the template to be a different one you need to update the template attribute in the layout. At it's most simple this can be achieved by editing app/design/frontend/base/layout/catalog.xml and changing the template attribute.
<block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="your/new/path.phtml">
Of course editing core files is a bad idea, so you should make a quick search for how to correctly add layout updates via either local.xml or customer layout update files.
I ended up figuring out what I needed to do. I simply wanted to add a small image to my product detail page that highlight a free shipping option. All I had to do was create a static block in the admin panel of magento and go into catalog>product>view.phtml file and insert:
getLayout()->createBlock('cms/block')->setBlockId('your_block_id')->toHtml(); ?>
it worked like a charm!
thanks for the help Crags

Joomla 1.5 How to divide joomla templet and use different page templet for different page

I am new in joomla and I am going to develop a web site with joomla 1.5.
For the site I have a html css template. Now I want to convert this into joomla template with different files (Header,Footer, sidebar etc).
Is it possible? if yes then how can i do this ?
and how can i make different page temples for my different page (such as about, Products etc)
Please help me....
I would recommend starting here:
http://docs.joomla.org/Creating_a_basic_Joomla!_template
http://docs.joomla.org/JDOC:Joomla!_1.5_Template_Tutorials_Project
I would also recommend visiting http://demo.yootheme.com or http://demo.rockettheme.com and finding one of their free templates (both have one or two, I believe) to download. That way you can analyze how a professional template is built and organized and apply it to your own project.
Your last question: To make different templates to apply to different pages. The simplest way is to follow the directions (above) to make/modify/install a second template. Then use the Joomla template manager and specify which pages apply to which template.
You can certainly create different files for each portion of a page but it's really not necessary in Joomla. There is only one "page" in Joomla, the index.php file. The entire website is built using that file. You can control the different parts - called positions in Joomla - of the website through 3 different methods
using conditional statements that determine whether they need to display at all
using modules to place content in the various positions
using CSS to control the display of each module
While it is technically possible to use multiple template in Joomla, it is almost always unnecessary. In the menu items used to create the pages in Joomla, you can specify a parameter called the page class suffix. You can insert this in to the body tag of your template giving you complete control of each page in the website through CSS rather than coding another template. Use this code to add the page class suffix to your body tag -
<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
$pageclass = "";
if (is_object( $active )) :
$params = new JParameter( $active->params );
$pageclass = $params->get( 'pageclass_sfx' );
endif;
?>
<body id="<?php echo $pageclass ? $pageclass : 'default'; ?>">
This is compatible with all the big frameworks as well.
If you want to show different header footer and sidebar on each pages. It can be easily possible in joomla. You have to simple create custom module in joomla and you control the display option of this module from the joomla administrator.

Resources