I need to display a CMS page inside my custom module's phtml file. Is there any way I can include it either through xml layout or via coding directly in phtml file? I know we can add a cms block but how can we add a cms page?
Try the below code in your phtml file
$page = Mage::getModel('cms/page')->load('home_page','identifier');
echo $page->getContent();
This code check if cms page is active then it will display page content
$page = Mage::getModel('cms/page')->load('top_offer','identifier');
echo $page->getIsActive()?$page->getContent():'';
Related
I am trying to add the SKU of the products to the product page by adding the following code:
<h3><?php echo $this->__('SKU:') . $this->htmlEscape($_product->getData('sku'));?></h3>
I have cleared Magento cache and deleted cache storage. Unfortunately, the changes on template file are not showing up ... any suggestion?
PHTML file need to be edited
PHTML file edited
Magento get data directly work like getSku(); Try echo $_product->getSku();
I have magento with cms module and I created static page, now I would like to add a some of products to this page.
How can I do that?
i've found this plugin http://www.fmeextensions.com/magento-add-products-to-cms.html but i want to do it by myself
You can add products from a category to a CMS page by ading this to your cms content - disable the wysiwyg editor when you paste it in;
{{block type="catalog/product_list" category_id="123" template="catalog/product/list.phtml"}}
Just change the category ID to the one you want.
How to get recently viewed products in magento.
I tried the following code also
$this->getRecentlyViewedProducts();
in the file product_viewed.phtml
1.Place code snippet below in any template u want to add
<?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>
2.Place code snippet below in any Backend cms-> page or static block
{{block type="reports/product_viewed" template="reports/product_viewed.phtml"}}
Replace template name, product_viewed.phtml with your site.
How can I put a php code on cms page in Magento?
Image here: http://screencast.com/t/COgHigLih7
I want to put
<?php
echo "Test";
?>
You can not add php code directly into the content of a cms page
What you could do is add your php code into a pthml and then call it from you cms page
{{block type="core/template" name="contactForm" template="contacts/my_php_code.phtml"}}
I have created CMS pages in Magento and I want to share with Social site using share buttons Facebook, Twitter, Google+ so any one to tell me how to do that ?
Add this part to :
your_package/your_theme/template/page/html/head.phtml
before this line --> <?php echo $this->helper('core/js')->getTranslatorScript() ?>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "ur-c297c92f-9661-1cf3-697d-47c19ab7e281"});</script>
Add this part to your cms page :
<span class='st_facebook_hcount' displayText='Facebook'></span>
<span class='st_twitter_hcount' displayText='Tweet'></span>
<span class='st_googleplus_hcount' displayText='Google +'></span>
NOTE: using sharethis extension
You can check below URL for Addthis button, select style of button you want to share, grab the code and add that code to Magento Admin >> CMS >> Pages. click on to Html view of Editor and paste the code which you have grab from Addthis site, and you will see share buttons on front end. Another method is you can add this code to your template file commonly used for Example 1column.phtml is used for CMS pages and you need Share buttons on all CMS pages then you can paste the same code in .phtml template file.
Add this : https://www.addthis.com/get/sharing#.UK8_PoafHcc
Although this is an old thread i would like to share my answer which i found.
Add a meta tag in
template/page/html/head.phtml
<meta property="og:site_name" content="yoursite.com"/>
Create a Custom Variable from System/Custom Variables by pasting the Facebook sharing button code to Variable HTML Value.
To add like/share button to cms or static block, use the “Insert Variable” button to insert the Custom Variable you have just created.