Category: "Tips for PHP"
JSON in Joomla
I am building a component using JSON in Joomla. That is very hard to do that. So far, I built in a view.json.php in views folder. But I could not call it. Well, that is easy! You just need to add a parameter ,format=json, in the url.
How to reference a javascript file in a Joomla Component
I am writing two Joomla components during these few days. I got a problem, how to reference a javascript file in a Joomla Component. I used to do it in a cowboy way. I hard coded the path in the template! I should keep it inside the component!
I found the documentation, in the framework, that is a method calls AddScript. It will add a script in the header section. That is nice!
Code
<?php | |
$document = &JFactory::getDocument(); | |
$document->addScript( 'components/com_<component name>/script/jquery.js' ); | |
?> |
But please adding this in the component xml file:
Code
<files folder="site"> | |
........ | |
<folder>scripts</folder> | |
</files> |
It makes sure the script folder will be deployed.
Reference:
Joomla Documentation
Joomla: tinymce.get is not a function
I have upgarded to 1.5.17. But I found the "Save" button for all edit views are not working. I got a javascript error:tinymce.get is not a function.
Then I found that seems to be a bug.
But Joomla got the patch.
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=17936
All you need to replace the onSave function is in plugins/editors/tinymce.php
Code
function onSave( $editor ) { | |
return "tinyMCE.execCommand('mceToggleEditor', false, '$editor');tinyMCE.triggerSave();"; | |
} |
Joomla Download Manager
I have used a few download managers in Joomla, such as DocMan and jDownload. But my lastest favour is Phoca Download. First of all, that is a GPL component and Joomla 1.5 native. Moreover, so far, that is very stable application. I have not found any bugs at all. In addition, that is only a component. It has plug-ins and modules. According to their documentation, they has some plug-ins can add the links to a file, category and section to an article. I have tried their module menu. That is very good. It can draw a menu to all sections in my homepage, that is good for the user browsing the by sections.
How to change the menu title.
Previously, I believed chaning menu title is in Menus->Menu Manager and edit the menu -> title. That is only for display at administration side. To change the display name in front page, you go to Extensions-> Module Manager. Each menu is related to a module, for example, there is a Main Menu module. So, you need to edit the module for changing the title.