Joomla RSS mod_feed pubdate - joomla

Is there a way to have the PubDate of RSSfeed displayed using mod_feed? If there isn't a way to do this, are there any extensions that can?

The core module doesn't show it, but the data would be there and could be shown using a template override. Read more about how overrides work in Joomla here:
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Now getting the date is a bit tricky since it's not stored plain as a PubDate property. It is instead stored as a JDate object. You can access the date property of the JDate object like this:
$feed[$i]->publishedDate->date
Documentation about JDate can be found here: http://docs.joomla.org/JDate/11.1

Echo out the following within your $j loop at (2.5) /modules/mod_feed/tmpl/default.php (recommend you override in your current template):
foreach ($feed->items as $key => $row) {
$pubDate[$key] = $row[feed->data['child']['']['rss'][0]['child']['']['channel'][0]['child']['']['item'][$j]['child']['']['pubDate'][0]['data']];
}
print_r($pubDate);

Related

Get categories in a Prestashop theme

I'd like to get all my categories in my header (header.tpl) of my Prestashop theme but it seems not working well...
My code header.tpl :
{$childCategories= Category::getChildren(0, 0, $active = true, $id_shop = false);}
{printf($childCategories)}
Issue : Error 500
The code you have written is not valid for smarty. Prestashop uses Smarty to render templates. Please, take a look to the rules if you want to avoid troubles like this. Also, you have a lot of examples in the default theme of Prestashop to learn more about coding in Smarty.
The right code would be:
{assign var='childCategories' value=Category::getChildren(1, 1, true, false)}
Arguments to be passed
$id_parent : The parent category id. The root id category is 1 and the home id category is 2.
$id_lang: The id language. You can check it in the localization area to get the id of a language. If you have enable multiple languages, you could use the $language variable to get the id. List of global variables in Prestashop.
$active: Return only the active caregories.
$id_shop: The id of a shop if you have got multiple shops in an instalation.
Printing variables to debug
If you want debug or see the variables, you could try the following snippets of code:
{* Print only the variable $childCategories *}
{$childCategories|var_dump}
or:
{* Print all variables *}
{debug}
A template header.tpl comes from FrontController.php function displayHeader().
Category doesn't exists there, because header.tpl is a comprehensive template used in all pages.
There are several hooks which you can use adding content there: displayHeader, displayTop, displayLeftColumn, displayRightColumn, displayFooter.
You can add all categories in any module and one of these hooks like that:
$category = new Category((int)Configuration::get('PS_HOME_CATEGORY'), $this->context->language->id);
$sub_categories = $category->getSubCategories($this->context->language->id);
// else code

Insert a k2 article into joomla database with php

I want to add an K2 article to a joomla DB with php. Can I just add a record to the article-table? Or do I I need to update any other table as well?
I have some fundamental knowledge of PHP and mySQL, but I would appreciate a nudge in the right direction for the correct syntax to do this.
Many thanks,
Håkan
I am doing the same but on K2 item save (not for the already saved items in K2). So that I can duplicate the items in K2 into articles in joomla, in one click on save on the K2 item creation panel.
An "item" in K2 is an "article" in Joomla.
I am overriding core K2 using the process I have mentioned in this post-> Joomla - Overriding getItem method
Then I have found out where the K2 saves the article, as in this post-> Joomla - Where is the code in K2 which saves a new item's Title and alias
Now, my next step will be to add a piece code to the override file's (K2's models\item.php) save() function, so as to save the same K2 item into joomla com_content table as well. You will find all the info in the posts I have mentioned. If something is not clear, leave a comment so I can revert to the query.
Good Luck!
For an article in Joomla 1.6 or later you must have an entry in the asset table as well and it has to be correctly created using the methods from JTableContent.
I've done this several times in Joomla 2.5 and later. Simply insert properly structured rows into the k2_items table in your Joomla database. You'll want to make sure each new row that gets added has a properly incremented id, though. Here's an example:
$data =new stdClass();
$data->id = null;
$data->title = $title;
$temp = strtolower($data->title);
$data->alias = str_replace(' ', '-', $temp);
$data->catid = $catid;
$data->published = 1;
$data->introtext = $introtext;
$data->fulltext = $fulltext;
Do the same with all the other K2 fields (there's a bunch of them) until you finally can write the following code:
$db = JFactory::getDBO();
$db->insertObject( '#__k2_items', $data, id );

Get params value from component Joomla 3.0

I have saved value like this in my component table fields params.
unique=1
default_value=Default
validate=Validate
validate_error_msg=Validate error messag
searchable=1
Now i want to get value in my component.So I am passing values in my component's view.html.php
in this way
$params = new JForm($row->params); but its not working.
Now I want to get value so I am taking like this
$this->params->getValue('default_value');
But its not work where as in Joomla 2.5 ,we can get value like this
$this->params->get('default_value');
Try like this
For Ex.
$param = JComponentHelper::getParams('com_users');
$default = $param->get('default_value');
Have you tried to use
$params->get('your_parameter_value_name');
instead of
$this->params->get('your_parameter_value_name');
It should work.

Echo Specific Category Description on Magento Frontend

I want to create a page in the Magento CMS, then echo specific category descriptions on it. What is the code snippet i will need to accomplish this. I am assuming I will need to reference the categories' unique id within the database to echo their description...
thanks for the help!
john
Using PHP:
$categoryId = 15;
$category = Mage::getModel('catalog/category')->load($categoryId);
if($category->getId()) {
echo $category->getDescription(); // Should escape this, blocks have $this->escapeHtml()
}
I don't know how to do this using magentos email/cms template markup (I don't think its possible) - unless you create a block or widget.

How do I get attribute set name?

I am trying to get attribute set name in Magento product view template. I can get attribute value by $_product->getAttributeText('attribute'), but how do I get attribute set name?
I would like to display an attribute only if it is belong to a certain attribute set.
Whenever you have a product object, you can access its attribute set like this:
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
$attributeSetModel->load($product->getAttributeSetId());
$attributeSetName = $attributeSetModel->getAttributeSetName();
This will give you the name of the attribute set, which you can then compare using strcmp:
if(0 == strcmp($attributeSetName, 'My Attribute Set')) {
print $product->getAttributeText('attribute');
}
For more sexyness you can shorten it to:
$attributeSetName = Mage::getModel('eav/entity_attribute_set')->load($_product->getAttributeSetId())->getAttributeSetName();
Try the following code:
$entityTypeId = Mage::getModel('eav/entity')
                ->setType('catalog_product')
                ->getTypeId();
$attributeSetName   = 'Default';
$attributeSetId     = Mage::getModel('eav/entity_attribute_set')
                    ->getCollection()
                    ->setEntityTypeFilter($entityTypeId)
                    ->addFieldToFilter('attribute_set_name', $attributeSetName)
                    ->getFirstItem()
                    ->getAttributeSetId();
echo $attributeSetId;
Find more info about Attribute Set in the following article.
Thanks
Joe's answer requires a couple of alterations in order for it to work.
Firstly it should be $_product not $product, and secondly there is an erroneous ')' in the last line.
The following code should be correct:
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
$attributeSetModel->load($_product->getAttributeSetId());
$attributeSetName = $attributeSetModel->getAttributeSetName();
Comparing to a text value can have problems if users decide to later change that text - which is easy to do in Magento for attribute sets. One other option is to use the underlying id instead which is never going to change.
You can get this by looking up the value of the attribute_set_id column in the database using
select * from eav_attribute_set;
This number is also in the edit link in admin which is in bold below
http://.../index.php/admin/catalog_product_set/edit/id/10/key/6fe89fe2221cf2f80b82ac2ae457909ce04c92c51716b3e474ecad672a2ae2f3/
Your code would then simply use that property of the product. Base on the id of 10 in the link above this would just be
if (10 == $_product->getAttributeSetId()) {
//Do work
}

Resources