2

Basically am wondering is if there is a way to use magento as an actual cms system.

i.e. i have an html chunk (static block?!) with some parameters (page_image, pagetitle)

<div class="thumb">
    <img src="[page_image]" />
    <p>[pagetitle]</p>
</div>

I would like to loop through a set of cms pages, and print a thumbnail section with that information.

I am a complete newbie to magento, and i cant figure this out with just the basics i learned through the tutorials xd.

What am actually asking are a few points:

  1. How can i create custom fields for specific cms-pages?
  2. How can i loop through those specific cms-pages and print a thumbnail sort of view

links to tutorials are much appreciated!

Thank you for your patience!

1

To create custom fields for Magento CMS page section, you can follow below links
https://www.atwix.com/magento/adding-custom-attribute-to-a-cms-page/
https://magento.stackexchange.com/a/53094/2443

To display CMS pages as thumbnail view, you can use below code.

$cmsPages = Mage::getModel('cms/page')->getCollection();
foreach ($cmsPages as $cmsPage){
     echo $cmsPage->getTitle();
     .. GET AND DISPLAY YOUR REQUIRED DETAILS ..
}

Edited:

To loop through the specific cms Pages, You can use addFieldToFilter for filtering. like,

Mage::getModel('cms/page')->getCollection()>addFieldToFilter‌​('YOUR_FIELD_NAME', 'YOUR_FILTER_VALUE')

reference

  • Thanks! I will try it and let you know. Can i somehow filter my cms-pages i want to show in that Mage::getModel('cms/page')->getCollection(); ? – hahaha Feb 4 '17 at 15:13
  • You can use addFieldToFilter for filtering. like, Mage::getModel('cms/page')->getCollection()>addFieldToFilter(''YOUR_FIELD_NAME', 'YOUR_FILTER_VALUE') reference seanbreeden.com/stackoverflow-magento-addfieldtofilter – Jaimin Sutariya Feb 4 '17 at 15:27
  • sorry to ask so many questions, but am a complete newbie! Where do i put the code with the foreach loop you gave me? i will create a layout for the page i want the thumbs to be in, and put it there? – hahaha Feb 4 '17 at 15:33
  • Yes, exactly, you have to put it in your phtml file where you are going to add your page's html code. – Jaimin Sutariya Feb 4 '17 at 15:38
  • hey man i did everything in the atwix tutorial and although i get the new field to show on the cms page, the value is not stored! I dont know what i missed, if you have some previous experience with some details i might have missed please let me know, i did this tutorial 3 times! – hahaha Feb 16 '17 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.