Hi Emmanuel;
I understand what you are saying but it is not what I want. I knew that I can create a new object by calling my new method. However this won't solve the issue that I have. I also tried your solution but it breaks the site.
Myplugin.php code is the following.
Code:
<?php defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.event.plugin');
class plgFlexicontentMyplugin extends JPlugin {
function plgFlexicontentMyplugin(&$subject, $params) {
parent::__construct($subject, $params);
// parent::__construct();
}
function renderCatItems(){....} //THIS IS MY METHOD NEEDED TO BE CALL
}
My category.php looks like
Code:
<?php defined( '_JEXEC' ) or die( 'Restricted access' );
// Category sections ordering
$cat_sections = $this->params->get('layout_ordering',array("subcats","items"));
if (is_array($cat_sections)){
echo '<div class="tmpl-'.str_replace('.category.','',$this->tmpl).' cat-'.$this->category->alias.'">';
foreach ($cat_sections as $cat_section){
if ($cat_section == 'items') { // Temporary to force testing my new method
echo '<div class="myfunction">';
//$a = new plgFlexicontentMyplugin(); ### NOT WORKING it breaks the site.
//$a = new plgFlexicontentMyplugin($this,);
dump($this,'check for plgFlexicontentMyplugin'); // To dump $this and look for my methods available. The dump image is attached.
$section= 'renderCat'.ucfirst($cat_section);
plgFlexicontentMyplugin::$section(); //The way it currently works
// $this->$section // The way I WOULD LIKE IT TO WORK
echo '</div>';
}
}
echo '</div>';
}
?>
I would like that my classes from my method be accessible from $this in my ../component/com_flexicontent/templates/category.php
The option that you are suggesting basicaly would make me have my object $this and $a.
Again I would like to extend available method of my object $this in ../../../category.php
For example: I use joomla com_dump to dump my $this when it get to ../../category.php. I am able to see that $this has the method display available. (NOTE: check the image attached)
Imagine that I am creating my on ->display method.
So I would like to call it $this->display. but instead it would be $this->$section; which it is the equivalent of $this->'renderCat'.ucfirst($cat_section); => equivalent to $this->
Please let me know if you want to do a skype or join.me
Mike Santana.
PS: I sent you an email but it bounced.