Joomla by default renders its system messages (errors, notices etc.) in
libraries/joomla/document/html/renderer/message.php.
For my own template, I would like to customize the way these messages are displayed. However it does not seem to be possible in the traditional way, using template overrides.
Is anyone here aware of a way to accomplish something like this?
For Joomla! 1.7 - 2.5
You need copy libraries/joomla/document/html/renderer/message.php in to templates/YOUR_TEMPLATE/html/message.php
Then in index.php of YOUR_TEMPLATE you need to include the file (as it is not automatically included like other overrides):
// Message overwrite
require_once JPATH_ROOT .'/templates/'. $this->template .'/html/message.php';
Now you can safety overwrite the JDocumentRendererMessage::render() function there ;)
For Joomla! 3.x
You just need make html/message.php file in YOUR_TEMPLATE. This file should contain function renderMessage(). Check the isis default template, as example.
Templates overrides only work with the MVC - i.e. views and module chrome.
Without hacking the core all you can do is control what HTML tags are wrapped around the <jdoc:include type="message" /> tag in the template and the CSS defined for the elements of the message block.
A more elegant way to include your override in the template directory is to include the file in a system plugin:
public function onAfterInitialise() {
$app = JFactory::getApplication();
if ($app->isSite()) {
$template = $app->getTemplate();
if (!class_exists('JDocumentRendererMessage') && file_exists(JPATH_THEMES . '/' . $template . '/html/message.php')) {
require_once JPATH_THEMES . '/' . $template . '/html/message.php';
}
}
return true;
}
http://extensions.joomla.org/extensions/style-a-design/popups-a-iframes/26551
OR
http://extensions.panchsoft.com/product/1-popup-system-messages.html
Use this extension for default messages for Joomla.
Related
I'm trying to integrate Codeigniter and Filterable but I cant find much information about it. I have a page with many results and I want to filter the results, for example by the column "name" or "id". I have worked with Filterable before, but never had to do it with Codeigniter.
I tried to put the files on the root. Also in the folder "Application", even tried putting it on the same folder as the view. But in any of these cases I cannot link the files and get it to work.
The ways I've been trying to link the scripts are the following:
<script src="<?php echo site_url('src/filterable.js')?>"></script> This was with the scripts in application folder
<script src="./src/filterable.js"></script> Scripts on root
<script src="<?php echo site_url('admin/src/filterable.js')?>"></script> Scripts on view folder
Is there another way to achieve this? Or maybe another library I could use for it?
Here is how I like to deal with assets.
I create an helper called assets_helper in application/helpers/
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('js'))
{
function js($nom)
{
return '<script src="' . base_url() . 'assets/js/' . $nom . '.js" type="text/javascript" ></script>';
}
}
//This is only the part that handle js as it is what's bothering you
Here is the full helper I use : http://pastebin.com/ujETEXJ4
After that, at the same level as index.php I create those folder :
|-Application
|-System
|-index.php
|-Assets
|- css
|- sass
|- images
|- js
Put all the js file you need in your new js folder.
In my application/config/autoload.php I add my new helper
$autoload['helper'] = array('assets', ...);
Finally, in the footer of my page(s) :
<?= js('myjsfile'); ?> //I did not forgot the extension, it's how it works :)
Which will give at the end :
<script src="http://www.example.com/assets/js/myjsfile.js" type="text/javascript" ></script>
Thanks AdrienXL for your answer. I tried to follow your suggestion but in the end I couldn't make it work. For some reason Codeigniter didn't recognize the files I tried to reach.
So after a long searching I ran across a library called Datatables http://www.datatables.net/ it has the option to load the scripts locally or remotely, so just added the link to the scripts needed to the type of filter I had to implement and in the end this last option was what allowed me to make the filters work.
I have a Joomla site, and I want to remove a the footer div from a page without it affecting it on the other pages. Please is there a way I can do it.
You have a couple options - you should be able to set additional CSS on that article to hide the particular footer div for that one individual page without issue.
Additionally you could install a plugin like Sourcerer that allows for PHP coding directly into articles in Joomla! (which comes in REALLY handy!); then you could remove it programmatically as well if necessarily.
Alternatively - you could create a template override for that particular template/page and edit the PHP there to reflect appropriate course of action for that URL/Page.
I tried to list them in order of easiest to most difficult.
It´s not a clean method to hide template-elements by using CSS (display:none). And for your intension you dont´t need a external plugin.
Try a page-option in your template index.php.
First - to get page-options work:
<?php $pageoption1 = JRequest::getVar( 'Itemid', '' ); $pageoption2 = JRequest::getVar( 'page', '' ); $pageoption3 = JRequest::getVar( 'option', '' ); ?>
And further:
<?php if ($pageoption1 == '1') { ?>
This text will be visible only in the page with Menu Item ID 1
<?php } ?>
This works lately in Joomla 2.5.X - for newer version i think it will also work fine.
Im trying to override the article layout for articles showing in the category blog layout. I have overriden the blog.php file from the folder components/com_content/views/category/tmpl into mytemplate/html/com_content/category, but this only overrides the category blog layout, not the layout of the actual articles.
The bit i need to override is the bit that loads inside here,
<article class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<?php
$this->item = & $item;
echo $this->loadTemplate('item');
?>
</article>
Any ideas how to do this without overriding every article on the site.
Thanks.
you should override this file:
components/com_content/views/category/tmpl/blog_item.php
Read More:
Customize Your Joomla Templates by Learning Overrides
You need to create another template over for the single article view. Place files to override from here:
components/com_content/views/articles/tmpl/
In here:
templates/myTemplate/html/com_content/article/
You can keep the names the same and every Article will use this template to render, or you can rename and manually assign the template to individual articles as needed.
Some links on the details on template overrides.
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
http://docs.joomla.org/Understanding_Output_Overrides
http://docs.joomla.org/Layout_Overrides_in_Joomla
Try to override the following tmpl files :"category/blog_item.php", "category/default_articles.php" and "article/default.php"
I have a javascript script that changes an image's src when clicked. When I had the same application in pure php without Codeigniter I simply had the images' src be something like "images/image_name" where images was the images folder, but now I'm using Codeigniter I don't know how to do it. I can't use php inside the JS script obviously so can't use the base_url() or site_url() functions or anything, so I suppose only the absolute path would work. And my images are in an images folder that's inside an assets folder which is at the root (i.e. at the same level as the Application, System and User_guide folders). So what should the images' src be? Thanks.
You can use php code inside script.
<script>
var imgSrc="<?php echo base_url('assets/images/image_name.jpg'); ?>";
</script>
Or you can also declare a global variable in header file to store base path.
<script>
basePath='http://www.yourdomain.com/';
</script>
and it can be used as
var imgSrc=basePath+"assets/images/image_name.jpg";
in addition to piyush's answer, I need to mention something that will help to use site_url() & base_url() properly.
site_url("controller/method/args") == base_url() + $config['index_page'] + /controller/method/args. You should use this to access pages.(Reference)
base_url("public/img/logo.png") == base_url() + /public/img/logo.png. You should use this to access resources such as images, stylesheets etc.(Reference)
Main difference between both functions is this part $config['index_page']. If you have already removed the $config['index_page'] from the config.php and you are using .htaccess to rewrite the URLs, then both function will result the same. But it is a best practice to use the correct function for the correct purposes.
Hope this helps.
Trying to use HeadJS in Joomla. I added a code to my template - it grabs the javascript files in the head output, prepares a string to output them between head.js code, then removes all javascript files from joomla's head output tag.
The problem is that some scripts are loaded after the template. For example, a module will enqueue some script files after the template has loaded, so its files appear outside of my head.js code. Any ideas how I can control this?
$data = $this->getHeadData();
if( $data['scripts'] ){
foreach ($data['scripts'] as $url=>$type){
if( !strstr($url, 'ajax.googleapis.com/ajax/libs/jquery') )
$headjs[] = $url;
}
unset( $data['scripts'] );
$data['scripts'][$template . '/js/head.js'] = array(
'mime' => 'text/javascript',
'defer' => false,
'async' => false);
$this->setHeadData($data);
}
And then...
<script>
head.js(
<? foreach($headjs as $script): ?>
'<?=$script?>',
<? endforeach; ?>
function(){
}
);
</script>
Different extensions can hook up to different events that are triggered during processing the output (so even after template is rendered).
Best option I found so far is creating system plugin and moving it's order to be the last of available system plugins.
Now you have two options:
use onBeforeCompileHead event (I guess introduced Joomla 1.5.23) to move scripts to headjs.
use onAfterRender event and parse head html code so it's loaded using headjs.
This is fine if you play around with async scripts loading where you have total control over the website, but it's almost impossible to implement as universal extension for Joomla. Some extensions use inline scripts in head, some in the the html body and you'd have to preserve order of execution (simple example: Mootools have to load first).
I use to load asynchronously only those scripts which I've included myself (in my template or my extension). Any scripts that are added with Joomla core (Mootools, core.js, etc.) or other extensions I don't touch.