shCustomHeadTag module for page-dependent css or javascript

Do you have an Open Source Product available for Joomla!? Let everyone know here.
Locked
shumisha
Joomla! Guru
Joomla! Guru
Posts: 520
Joined: Sat Aug 20, 2005 3:15 pm
Contact:

shCustomHeadTag module for page-dependent css or javascript

Post by shumisha » Fri Feb 16, 2007 12:22 am

Hello !

I read a short while back an article on corephp.com (http://www.corephp.com/developer_center/p,38) about getting more control on your joomla page by having some css styles that could vary in relation with the page being displayed. The people at corephp came up with a simple solution to do that, which implied making a small change to the index.php template.
I have used in some modules of mine a technique that can be used to do just that, but directly from the backend. It is a module (shCustomHeadTag) you can publish in any position.
The module will either :
- put some text you enter in the backend in the >head/head< section of the page. Can be some javascript, some css styles or links to external js or css stylesheets
- replace the first or all occurences of a text tag by some replacement text. The tag is just free text you type in the backend

The nice thing is that, if the module is loaded last on the page, or at least after the call to mosMainBody(), it can act as a mambot and replace some text in your regular content (I use that to display a slideshow in content, but withouth the need for a mambot)

Because this is just a module, you can make as many copy as you need, and publish each copy on a given set of pages to achieve  what you want.

Take a look at http://forge.joomla.org/sf/projects/shcustomheadtag
4SEO, all-in-one SEO extension for Joomla 3 & 4 - https://weeblr.com
I don't reply to PM anymore. Thanks for using 4SEO and wbAMP

User avatar
emanuel37
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Sep 12, 2006 2:35 pm
Location: Zürich

Re: shCustomHeadTag module for page-dependent css or javascript

Post by emanuel37 » Sat Feb 17, 2007 2:53 pm

Hi shumisha

very nice module, I searched and waited for a long time to get anything like this..

Basically, everthing runs great.

But I have a slight problem with linebreaks/newlines in javascripts:

Code: Select all

<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','864','height','162','title','blinzeln','src','templates/saentis/images/blinzeln','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','templates/saentis/images/blinzeln'....
I get something like

Code: Select all

<script type="text/javascript">
<br />AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shock
It modifies simple line feeds into html line breaks .

Do you have a clou where this comes from?

Best regards emanuel

shumisha
Joomla! Guru
Joomla! Guru
Posts: 520
Joined: Sat Aug 20, 2005 3:15 pm
Contact:

Re: shCustomHeadTag module for page-dependent css or javascript

Post by shumisha » Sat Feb 17, 2007 3:23 pm

Hi Emanuel,

Thanks for your comments. I have looked into it a bit, and it seems it is joomla parameters handling system that adds
instead of \n. It seems it process the parameter text area as HTML input rather than plain text. Right now, I can't try to find a fix for that. I would suggest the following quick fix: simply do not use any line breaks, just add you javascript as one line ! What I do for javascript myself is maintain a source version, with full comments and nice formatting, and then run that through crunchinator (http://www.brainjar.com/js/crunch/demo.html) to get it all on one line with all comments removed.

That's all I can suggest for now, I did not suspect joomla would add those
in a text area, I need to research that !
4SEO, all-in-one SEO extension for Joomla 3 & 4 - https://weeblr.com
I don't reply to PM anymore. Thanks for using 4SEO and wbAMP

User avatar
emanuel37
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Sep 12, 2006 2:35 pm
Location: Zürich

Re: shCustomHeadTag module for page-dependent css or javascript

Post by emanuel37 » Sat Feb 17, 2007 4:33 pm

thanks for the quick reply, shumisha.
Yes, that's the way I use it currently.
It just was a comment to clarify, as you announce the module for using js.

Many thanks anyway.


Locked

Return to “Open Source Products for Joomla!”