I have been assigned to create joomla template from HTML template, and this is first time for me. In HTML template I have a custom JS, and as far I can tell, I will need to create one, or maybe two custom modules in order to recreate functionality that exists. Is there some way to write JS for specific module and load it in footer (this module will be active only on one page, so I don't want to load JS on all pages). Is it possible to do this, or the simplest way is to load JS on everypage?
Please read the Joomla documentation on creating modules Creating a simple module and then on your module file mod_mymodule.php add the script call using:
$doc = JFactory::getDocument();
$doc->addScript( JUri::root() . "media/your_js_directory/your_script.js" );
Hope it helps.
Related
i look for a way to load widgetkit in any module. For example in mod_content. I dont want to use default joomla! {loadposition #} to load another widgetkit module in mod_content.
I think that is more straightforward to user widgetkit shortcode in module. this doesnt work on some sites. On some sites it works.
Has anyone an idea how to solve it? Thank you.
Make sure the "Prepare Content" option in basic configuration of the module is enabled. However you might want to use a widgetkit module and a content module to keep things separate.
Insert the shortcode of the widget...e.g. [widgetkit id=4].. then select yes in the prepare content in the basic options of the custom html module.
I created a custom module called Drawings. I wanted to give it its own theme layout on the frontend, so I followed the advice I found HERE - I put a layout file titled Drawings.html in my theme.
This had the correct effect on the frontend, but caused other problems and questions that I've been struggling to sort out:
The backend admin section for my module now uses the Drawings.html layout, which breaks its functionality completely. How can I set a specific layout for my module front end, but keep the standard admin backend layout (same backend implementation as in the sample module tutorial)?
I read the following in the Template Library: "When using Public_Controller and Admin_Controller, the layout is already set." Perhaps the solution involves using the set_layout function in these controllers somehow? All my attempts failed so far though.
I feel I am doing something incorrectly because now my module is not modular. For example, after creating the Drawings.html layout file in the theme, a statement like {{ theme:css file="drawings.css"}} in that layout file searches for those resources in my theme. So I have to put those JS and CSS resources in my theme, instead of in my module's CSS and JS folders. How do I keep and access my resources in the module's JS and CSS folders?
I don't know how this is supposed to work.
When you are using front end controller use a layout there using philsturgeon template library like this
function index(){
$this->template->set_layout('drawing')
->build('yourview');
}
This way you can load a custom layout for your application.
Im new to Magento. I would like to know how can I place static javascript code across all pages of the magento site. The JS code does some initilization and includes another hosted js file. Also, I would like to add this code in footer of all pages.
Any guidance/docs/codes welcomed.
Thnx in advance...
The fastest way is to create a new file in the "js" folder in the root
of your website. To include the Javascript file in the code, go to
System -> Configuration -> Design -> Footer -> Miscellaneous Scripts
And add your script there like you would normally do.
There are other ways, but this is the easiest way to do it.
Edit: Changed HTML head to Footer, thanks dagfr
- Edit -
The above example is not what he meant, he wants to add JS to the footer, so when he distributes the module, the JS will also be in the footer.
Answer
You can use the layout .xml file for your module to add a JS file.
To do this, you can add the following code:
<action method="addItem"><type>js</type><name>script_name_here.js</name></action>
In order to place it in the footer, you will have to make a new block, which is explained in the following article.
I'm prepare a multistore on magento.
I have a three template, and I was change a few file from code/core and replace in code/local, but only one template take a changing code from code/local
a rest template should take file from code/core/
Now every template take files from code/local/
How can I'm set app to resolve a problem
thx for help
You should NOT overwrite core files in local. Better try to develop your own module which rewrites the core functionality. In this module you can integrate a configuration, so it's only used for one store view, and not for all.
I am in the process of writing a custom component along with some custom modules in Joomla 1.7 and I am having trouble figuring out how I can use function within my component inside my custom modules. I don't want to duplicate these functions because there's a very good chance of those getting out of sync when changes are made.
Can I just include a file to get access to those functions?
Thanks!
Shure. You can always do stuff like this inside modules:
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_mycompo'.DS.'helpers'.DS.'helper.php');
and then
$settings = & MyHelper::myHelperFunction();