Show images in Joomla 3.10 search results (com_search) - image

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?

Related

sorting and filtering not working in custom admin module

I am trying to implement an admin module in magento which has a grid in the first page and grids in the tabs while editing the grid entities.
The main grid works fine, but the grids in the tabs are not working fine.
The problem I found while I debugged the code is that, I am loading the collection in the grid with field filtering, ie I am filtering the collection with filter that is the user id. I did this because I need only data of a single user from the table. This made the entire problem, the data in the grid is coming correctly, but the filtering,sorting and searching feature inside grid is not working and returning a 404 not found error page. I tried removing the field filter I added while getting the collection, then it works fine but all the data in the table is coming which is the opposite to my requirement.
Is there any possible solution to this. Here is the way I am trying to do:
protected function _prepareCollection() {
$collection = Mage::getModel('merchant/subscriptions')->getCollection()->addFieldToFilter('user_id', Mage::registry('merchant_data')->getId());
$this->setCollection($collection); //Set the collection
return parent::_prepareCollection();
}
Thanks in advance.
ok My problem is solved there is a mistake in my code. In the grid file the function below was wrong.
public function getGridUrl() {
return $this->getUrl('*/*/transactiongrid', array('user_id',Mage::registry('merchant_data')->getId(), '_current' => true));
}
The correct method was
public function getGridUrl() {
return $this->getUrl('*/*/transactiongrid', array('user_id'=> Mage::registry('merchant_data')->getId(), '_current' => true));
}
Filter action is dependent on your below method:
public function getGridUrl() {
return $this->getUrl('*/*/grid', array('user_id' => Mage::registry('merchant_data')->getId(),'_current'=>true));
}
now this is how you will prepare collection:
protected function _prepareCollection()
{
$regData = Mage::registry('merchant_data');
if(isset($regData))
$regData = $regData->getId();
else
$regData = $this->getRequest()->getParam('user_id');
$collection = Mage::getModel('merchant/subscriptions')->getCollection()->addFieldToFilter('user_id',$regData);
...
When I dumped $regData I got this:
Cubet_Merchant_Model_Merchant Object
(
[_eventPrefix:protected] => core_abstract
[_eventObject:protected] => object
[_resourceName:protected] => merchant/merchant
[_resource:protected] =>
[_resourceCollectionName:protected] => merchant/merchant_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[user_id] => 3
[firstname] => Robin
[lastname] => Cubet
[email] => robin#cubettech.com
[username] => robincubet
[password] => 51a7f45eb11fc49b5967a0039193c3ad:HSX8JkSO5lr3uaRHrzd86i7gb0RATeDb
[created] => 2013-12-12 08:34:28
[modified] => 2013-12-16 09:03:56
[logdate] =>
[lognum] => 0
[reload_acl_flag] => 1
[is_active] => 1
[extra] => N;
[rp_token] =>
[rp_token_created_at] =>
)
[_hasDataChanges:protected] =>
[_origData:protected] => Array
(
[user_id] => 3
[firstname] => Robin
[lastname] => Cubet
[email] => robin#cubettech.com
[username] => robincubet
[password] => 51a7f45eb11fc49b5967a0039193c3ad:HSX8JkSO5lr3uaRHrzd86i7gb0RATeDb
[created] => 2013-12-12 08:34:28
[modified] => 2013-12-16 09:03:56
[logdate] =>
[lognum] => 0
[reload_acl_flag] => 1
[is_active] => 1
[extra] => N;
[rp_token] =>
[rp_token_created_at] =>
)
[_idFieldName:protected] => user_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)

Adding address to mailchimp using Gibbon gem

Im using the gibbon 0.4.6 with ruby 1.9.3p392, and I tried to add the address of my contacts but I couldn't find the correct format of the parameters.
respuesta = gb.listSubscribe({
:id => lista_id, :email_address => email,
:merge_vars => {'FNAME' => nombre, 'LNAME' => apellido,
'MMERGE3' => ['addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF',
'zip' => '06700', 'country' => 'MX']
}
})
Update
As Amro suggested, now Im using Gibbon 1.0, but I have the same problem:
I used this
respuesta = gb.lists.subscribe({
:id => lista_id, :email => {:email => email},
:merge_vars => {'FNAME' => nombre, 'LNAME' => apellido,
'MMERGE3' => {'addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF', 'zip' => '06700', 'country' => 'MX'},
'MMERGE4' => 'Mi nota '
}
})
But the address(MMERGE3) wasn't registered at MailChimp.
Any idea is welcome.
Your current code looks reasonable to me. Have you tried also passing "update_existing" with a value of true? If that address is already subscribed then it won't work otherwise since "update_existing" defaults to false.
Old Answer for API 1.3
I'm Gibbon's maintainer. In this case, MailChimp's docs say the type is an "array," but they mean an associative array (i.e. a Ruby hash). So try something like this:
respuesta = gb.listSubscribe({
:id => lista_id, :email_address => email,
:merge_vars => {'FNAME' => nombre, 'LNAME' => apellido,
'MMERGE3' => {'addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF',
'zip' => '06700', 'country' => 'MX'}
}
})
Also, API 1.3 has been deprecated. I suggest upgrading to Gibbon 1.0, which hits MailChimp API 2.0. The syntax is a little different so be sure to check out the 2.0 docs and Gibbon's updated README here.

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...
);

Magento - Show Creation Date/Time for CMS pages

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...

Setting Validation Rules at Runtime in CakePHP

My problem right now is that a Model has a set of Validation rules like so:
var $validate = array(
'title' => array(
'rule' => 'notEmpty'
),
'uri' => array(
'slugged' => array(
'rule' => '/^[a-z0-9-_]+$/i',
'message' => 'This field should only contain characters, numbers, dashes and underscores'
),
'uniqueUrl' => array(
'rule' => array('uniqueUrl'),
'message' => 'A page has already acquired this url'
)
),
'meta_keywords' => array(
'rule' => 'notEmpty'
),
'meta_description' => array(
'rule' => 'notEmpty'
),
'layout' => array(
'rule' => 'notEmpty'
)
);
The problem is that in another model that has hasOne relationship its controller also inserts data into it. I want to NOT require the title, uri and layout from that page. How do I do it?
I have a Post Model and I set Page values from there.
Array
(
[Post] => Array
(
[title] => data[Post][title]
[body] =>
Post Body
)
[Category] => Array
(
[Category] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
)
[Page] => Array
(
[meta_keywords] => data[Page][meta_keywords]
[meta_description] => data[Page][meta_description]
)
)
I do this from the controller to set info for the Page model
$this->data['Page']['title'] = $this->data['Post']['title'];
It turns to be like this:
Array
(
[Post] => Array
(
[title] => data[Post][title]
[body] =>
Post Body
)
[Category] => Array
(
[Category] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
)
[Page] => Array
(
[meta_keywords] => data[Page][meta_keywords]
[meta_description] => data[Page][meta_description]
[title] => data[Post][title]
)
)
My problem is that I do not require a Page field when saving. Post belongsTo Page.
I don't require [Page][layout] when saving a Post as a Post uses the default view of the method in the Post Controller. A page uses static pages and require them when creating a Page, not when creating a Post.
You're preprocessing the data before it goes for validation, so you're taking some control away from validation. As you seem to be making the decision (in code) whether or not certain fields need to be artificially populated you are rendering those parts of the validation redundant and you should remove them. If you have multiple validations in php, you're going to end up confused.
Where to do this or how to do it more cleanly? WellbeforeValidate might be the 'correct' place to do this, but I would do it wherever it best fits with the logic of your application. Function should come before elegance.

Resources