Magento - Show Creation Date/Time for CMS pages - magento

I have created a custom CMS layout by copying (and renaming) the 2columns-left.phtml and setting the appropriate xml configuration options, etc.
I would like to display the CMS Creation Time (the creation_time field) below the content. How do I do it?
Alternatively, in a CMS layout page, how can I access the underlying CMS page data?

<?php
$collection = Mage::getModel('cms/page')->getCollection();
foreach($collection as $page) {
print_r($page->debug());
}
?>
[Array]
(
[page_id] => 2
[title] => Home Page
[root_template] => three_columns
[meta_keywords] =>
[meta_description] =>
[identifier] => home
[content] => Hello...
[creation_time] => 2012-01-11 21:15:34
[update_time] => 2012-01-11 21:18:16
[is_active] => 1
[sort_order] => 0
[layout_update_xml] =>
[custom_theme] =>
)
Here is the array, rest of things its up to you...

Related

Show images in Joomla 3.10 search results (com_search)

I wanted to show intro image of articles in Joomla 3.10 search results (com_search).
In previous Joomla 3 versions I know that you could do this:
Create template override:
/templates/template_name/html/com_search/search/default_results.php
Then use this code
$images = json_decode($result->images);
to get access to the images.
Now I see in Joomla 3.10 that $result only has these values:
[relevance] =>
[title] =>
[metadesc] =>
[metakey] =>
[created] =>
[language] =>
[catid] =>
[text] =>
[section] =>
[slug] =>
[catslug] =>
[browsernav] =>
[href] =>
[jcfields] =>
[count] =>
Is there any way to get access to article images?

How to get module's title in Joomla 2.5?

Inside my module (from within php code), say mod_mymodule, how can I retrieve my module's title, in case an administrator has changed it from the module management page?
Is it possible to retrieve the "Status" and "Position" the same way as the title?
Inside the module, there are two helpful variables available:
$module and $params.
You are looking for $module->title.
Try the below code.
<?php
if ($module->showtitle)
{
echo '<h2>' .$module->title .'</h2>';
}
?>
You can access the following things.
stdClass Object
(
[id] => 18
[title] => Login Form
[module] => mod_login
[position] => left
[content] =>
[showtitle] => 1
[control] =>
[params] => greeting=1
name=0
[user] => 0
[name] => login
[style] =>
)
Reference Joomla URL:
1. http://docs.joomla.org/JModuleHelper/getModule
2. http://docs.joomla.org/Customising_the_way_modules_are_displayed
Updates - 22nd Dec 2016
You can use jimport to get the module.
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule( 'login' ); // Single
$module = JModuleHelper::getModule( 'mainmenu', 'Resources' ); // Multiple

How to get a list of cms pages in Magento?

What i'm trying todo
I have created an admin form where the user needs to select a CMS page from a drop down.
What i have tried
$form->addField('cms_page_id', 'select', array(
'label' => Mage::helper('custom/data')->__('CMS Page'),
'class' => 'required-entry',
'required' => true,
'name' => 'cms_page_id',
'values' => Mage::getSingleton('cms/page')->toOptionArray(),
'value' => $this->getCmsPageId()
));
The idea is the code gets the an option array from the CMS model. However "toOptionArray" is an invalid function for the 'cms/page' model.
My Question
How can I get an option array of CMS pages for use in an admin form in Magento?
With your code you are loading a new cms page model. To get a collection use following code and toOptionArray() will at least return something:
Mage::getModel('cms/page')->getCollection()->toOptionArray()
CMS Pages array with Links
$cms_arr = Mage::getModel('cms/page')->getCollection()->toOptionArray();
$cms_pages[""] = "-Select CMS Page-";
foreach($cms_arr as $cms){
$url = $this->getUrl($cms["value"]);
$cms_pages[$url] = $cms["label"];
}

Codeigniter: creating helper with associative array

I have a number of social networking links (about 5) in the footer of my site and I need to generate data for each of the anchor link’s TITLE and URL - and ICON (image).
It’s not really worth creating a new table for only 5 rows, so I’m thinking a helper might be a the answer - some sort of associative array.
However, I’m a bit unsure how to construct the helper’s array - and completely clueless as to how to loop the results in the view file.
Any help, or any links to useful examples, is greatly appreciated!
In your helper:
function footer_link_data()
{
return array(
array(
'title' => 'Facebook',
'url' => 'http://facebook.com',
'icon' => 'http://placehold.it/64x64'
),
array(
'title' => 'Twitter',
'url' => 'http://twitter.com',
'icon' => 'http://placehold.it/64x64'
),
array(
'title' => 'Pinterest',
'url' => 'http://pinterest.com',
'icon' => 'http://placehold.it/64x64'
),
);
}
In your view:
<?php
$links = footer_link_data();
foreach($links as $link): ?>
<?php echo $link['icon'] ?>
<?php
endforeach; ?>
Alternatively, you can just create the HTML statically. For 5 links having it generated dynamically is kind of pointless.

How to get the custom values and image in Magento in Topmenu?

I'm using magento 1.7.0.2. I have add the custom value in database. But how to retrive the custom value and image in Topmanu. I have tried in below mentioned code in the palce of 'my_attribute' to replace my attribute, but i din't get the result.
Model: Mage_Catalog_Model_Observer
Method: _addCategoriesToMenu()
$categoryData = array(
'name' => $category->getName(),
'id' => $nodeId,
//'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
'is_active' => $this->_isActiveMenuCategory($category),
'my_attribute' => $category->getData('my_attribute') // Add our data in...
);
When i print the array i'll get this,
Array ( [name] => Matelas [id] => category-node-31 [is_active] => 1 [my_attribute] => )
Can any one guide me, Thanks in advance...
I am guessing you mean you have added a new custom attribute to the Category entity?
Becuase you are dealing with a Node_collection the full category object won't be loaded, try loading the full object to get what you're after:
$cat = Mage::getModel('catalog/category')->load($category->getId());
$categoryData = array(
name' => $category->getName(),
'id' => $nodeId,
//'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
'is_active' => $this->_isActiveMenuCategory($category),
'my_attribute' => $cat->getData('my_attribute') // Add our data in...
);

Resources