How to use breadcrumbs in Joomla in custom components? - joomla

I wrote simple component by this example, but when i entering it i see Home instead of my components name.
And also is it possible to get deeper, for example joomla->my_component->some_other_component, but exactly after mine.
P.S.
Found http://docs.joomla.org/How_to_add_breadcrumbs, but how use it automatically in every view?

Try this:
$mainframe = &JFactory::getApplication();
$pathway =& $mainframe->getPathway();
$breadcrumb = $pathway->setPathway(array());
$pathway->addItem( JText::_( 'YOUR_BREDCRUMB_ITEM' ),'');
Replace YOUR_BREDCRUMB_ITEM with your item name. Hope this will help.

Related

Joomla display view not displaying site template

I am trying to load a view from my controller using the follow code but I only get a raw HTML view and does not show the site's template.
$view = $this->getView( 'download', 'html' );
$view->display();
Can some help me in what I am doing wrong to display the site's template.
I also tried a redirect but that did not work either
$this->redirect(JRoute::_('index.php?option=com_atdwcsv&view=download'), false);
Edit: I figured out what was wrong with the redirect. Code I needed was
$this->setRedirect('index.php?option=com_atdwcsv&view=download');
$this->redirect();
I could be wrong, but I don't think you need to use the display() method on the view, I think you need to use $this->display(); instead.

Creating task or a view for search results

I'm making a search for joomla, after clicking search button I am getting this url:
index.php?searchword=aa&task=search
How can I create a view or task for it?
If you use the basic joomla search component you will find the views in
/components/com_search/views/search/tmpl
If you edit the view then its advisable to use template overrides, to ensure you will not lose your views on upgrade : http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
addition :
If you are building a component and you want a task to execute like that, then use this in your YourComponentName.php.
$controller = JController::getInstance('FrontendSuite');
$controller->execute(JRequest::getVar('task'));
$controller->redirect();
And add the task as a function in your controller.php. You will get something like this :
function search(){
$searchword = JRequest::getVar('searchword');
//Do your magic
}
As Valentin pointed out just below, you will need to add option=com_yoursearchcomponent to your URL for Joomla to call your component.
Adding Views to your component is explained quite well in the link Valentin posted below, http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_a_view_to_the_site_part
Hope this helps,
Good luck
Your URL will be like:
index.php?option=com_yoursearchcomponent&task=search&keyword=xxx
So you need to create a component. Have a look at the Developing a Model-View-Controller Component.
Then you will have in your controller or subcontroller the task search which will call the view search, where you will have the appropiate template for the view.

CodeIgniter - adds an extra class to my URL when i click on a link

I'm new in CI as well in php. I have a problem that's bugging me for two days now:
when i click on a link in my admin header(say: Articles) it takes me to: www.example.com/admin/articles, which is ok. If now i try to click on another link in the header (say: Add articles), the url becomes: www.example.com/admin/admin/add_articles - it adds an extra admin to my url. if i click again on Articles, the url will be: www.example.com/admin/admin/admin/articles, and so on.
Do you have any idea why is this happening?
Thanks
You have 2 choice, the first is that you wrote in every link base_url()
OR
you can use a built in helper:
anchor('route','label','attributes')
in your example:
anchor('admin/add_article','Add an article',array('class' => 'link'))
Then that will create this HTML code:
Add an article
use absolute urls not relative, use $config['base_url'] before every link
Don't use
$config['base_url] . 'controller/action',
use the function:
site_url('controller/action');
Or use the anchor function #András Rátz suggested.

Place certain article anywhere in joomla template

Is it possible in Joomla to place a certain article in a template, additionally to the normal content? I want the article to show up on every page.
You can simply take it from the databse and print its content. In the template, where you want to show the article, write this:
$id=/*Id of the article to show*/;
$db=&JFactory::getDBO();
$db->setQuery("SELECT * FROM #__content WHERE id=$id");
$item=$db->loadObject();
echo $item->introtext;
UPDATE: ENABLE PLUGINS
I can't find where i've used that code and i can't copy-paste it, so i try to write it again by looking at the view.html.php of the com_content:
JPluginHelper::importPlugin('content');
$dispatcher =& JDispatcher::getInstance();
$params = &$mainframe->getParams();
$dispatcher->trigger('onPrepareContent', array (&$item, &$params, 0));
//The last line triggers the onPrepareContent event, so if it does not work maybe you need other events, so try with onAfterDisplayTitle, onBeforeDisplayContent or onAfterDisplayContent
Have you seen this? http://extensions.joomla.org/extensions/news-display/content-embed/7528
It allows you to place any article as a module on your Joomla site. And with modules you can have them displayed site wide.

Loading a module in another module in Joomla

I'm an absolute beginner using Joomla. I'm trying to load a module within another module but I can't find how to do this. I've been trying adding
{loadposition position}
with "position" replaced the position of the module I'd like to be loaded but it seems to work only in articles.
I've found another solution here : http://forum.joomla.org/viewtopic.php?p=1531754&sid=bae9b487983c7e8a9f9c4fbd2958cf52#p1531754
but I don't know where to put this PHP code in my module.
Thanks for helping !
You need to manually add the code to render your inner module to your container module. Heres an example:
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule('mainmenu');
$attribs['style'] = 'xhtml';
echo JModuleHelper::renderModule( $module, $attribs );
Taken from:
http://docs.joomla.org/JModuleHelper/renderModule
To display the output you would need to place the code in the section of your outer module source that you want the html to be rendered.
Where you would replace 'mainmenu' with the name of the module that you want to embed. (I removed the second param, as I'm assuming you don't want to display a title).
If you need to bring another module other than the menu (every where always show you a module)
This is my trick: (works in 2.5 and 3.0)
Go to your module and create a fake position only for this like "oehelp" in this case.
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$options = array('style'=>'raw');
echo $renderer->render('oehelp',$options,null);
voila,
saludos

Resources