Find out more about the “Show Off Your Avatar Campaign
RocketTheme  |  General  |  Free/GPL/Tutorials Discussions  |  Topic: Excluding code/scripts from pages « previous next »
Pages: [1] 2 3 Go Down Print
Author Topic: Excluding code/scripts from pages  (Read 21771 times)
James S!
Muffin Man
RocketTheme
Hero Rocketteer
*
Offline Offline

Posts: 38324


Firebug...Firebug...Firebug!

WWW
Excluding code/scripts from pages
« on: November 24, 2007, 04:44:41 AM »

This little guide will show you how to exclude an element such as a script from a page on your Joomla site. For example, if you had a component such as gmaps and was conflicting with mootools; then you can exclude mootools from that page in the index.php.

The first step is to find your code in the index.php in which you wish to edit, such as the example below
Quote
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/templates/<?php echo $mainframe->getTemplate(); ?>/js/mootools.js"></script>

It does not have to be a script, it could be module PHP code, or just normal HTML.

Opening Tags
The second stage is to wrap the code in some PHP syntax. Below are examples of the opening tags
<?php if ($option != "com_contact") : ?>
<?php if ($task != "registers") : ?>

Extraction Examples
These are associated with the following links
www.yoursite.com/index.php?option=com_contact&Itemid=3
www.yoursite.com/index.php?option=com_registration&task=register

Closing Tags
You would then end the code with a closing tag
<?php endif; ?>

Full Examples
Below is a full example with the above stages
Quote
   <?php if ($option != "com_contact") : ?>
   <script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/templates/<?php echo $mainframe->getTemplate(); ?>/js/mootools.js"></script>
    <?php endif; ?>

Example: excluding pathway from the frontpage
Quote
   <?php if ($option != "com_frontpage") : ?>
<div class="pathway">
<?php mosPathway(); ?>
</div>
    <?php endif; ?>

Hiding the frontpage
Example: excluding Mainbody (where content is loading) from the frontpage
Quote
   
<?php if ($option != "com_frontpage") : ?>
       <?php mosMainbody(); ?>
<?php 
endif; ?>

In Joomla 1.5:
Quote
   
<?php if (JRequest::getVar('view') != 'frontpage') : ?>
       <jdoc:include type="component" />
<?php endif; ?>
« Last Edit: October 05, 2008, 06:16:04 AM by James S! » Logged

Firebug Video Tuts: - Editing HTML - Javascript Errors - Logo Changes

Video tutorials on how to use Firebug, its what we use Smiley
myironlung
Newbie
*
Offline Offline

Posts: 9

Re: Excluding code/scripts from pages
« Reply #1 on: May 06, 2008, 01:49:02 AM »

If I wanted to stop the rotating header from rotating in the modern business template for a certain page (just one page or two, say com_content&task=view&id=50&Itemid=39 and the contact us page) on a website how would I do it?
« Last Edit: May 06, 2008, 02:27:00 AM by Brian Conneely » Logged
James S!
Muffin Man
RocketTheme
Hero Rocketteer
*
Offline Offline

Posts: 38324


Firebug...Firebug...Firebug!

WWW
Re: Excluding code/scripts from pages
« Reply #2 on: May 07, 2008, 12:53:53 AM »

You'd use

<?php if ($Itemid != "39") : ?>
Logged

Firebug Video Tuts: - Editing HTML - Javascript Errors - Logo Changes

Video tutorials on how to use Firebug, its what we use Smiley
KeenEye Design
Newbie
*
Offline Offline

Posts: 19

Re: Excluding code/scripts from pages
« Reply #3 on: June 28, 2008, 08:19:28 AM »

Does this code get placed in between the <head> tags?  Also how would you go about having a javascript popup only pop up when the frontpage is loaded.  Right now on each menu selection a new pop up comes up.  I've tried all these fixes and havent had success with either one:

1st ONE: <?php if (JRequest::getVar('view') != 'frontpage') : ?>
   <SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=450,height=450');");
}
// End -->
</script>
    <?php endif; ?>

2nd ONE: <?php if ($option != "com_frontpage") : ?>
   <SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=450,height=450');");
}
// End -->
</script>
    <?php endif; ?>

In both cases I have the following code placed within my body tag as well:

<body onLoad="javascript:popUp('http://www.eventfactor.net/cms/templates/EventFactor/media/music_player.html')">
Logged
James S!
Muffin Man
RocketTheme
Hero Rocketteer
*
Offline Offline

Posts: 38324


Firebug...Firebug...Firebug!

WWW
Re: Excluding code/scripts from pages
« Reply #4 on: June 28, 2008, 09:16:35 AM »

What Joomla version are you using?
Logged

Firebug Video Tuts: - Editing HTML - Javascript Errors - Logo Changes

Video tutorials on how to use Firebug, its what we use Smiley
KeenEye Design
Newbie
*
Offline Offline

Posts: 19

Re: Excluding code/scripts from pages
« Reply #5 on: June 28, 2008, 09:17:37 AM »

1.5
Logged
Anastasia Kiryanova
Newbie
*
Offline Offline

Posts: 8


How to exclude Mainbody from frontpage??
« Reply #6 on: July 05, 2008, 11:37:58 AM »

Hi!

I am trying now since hours to exclude the Mainbody section from the frontpage without success. Can anybody help me?

Before - in the index.php of the template - I had the code:
Code:
<div id="component-size">
<?php mosMainbody(); ?>
</div>

and I changed it to

Code:
<div id="component-size">
<?php if ($option != "com_frontpage") : ?>
<?php mosMainbody(); ?>
<?php endif; ?>
</div>

still the content is shown on the frontpage.

somebody an idea what i getting wring here?

thanks!

Anastasia
Logged
GollumX
Professional
Hero Rocketteer
*
Offline Offline

Posts: 2745


Got Coffee?

Re: Excluding code/scripts from pages
« Reply #7 on: July 05, 2008, 05:57:19 PM »

You can't have a page without a component. Every page in Joomla is built around a component.

It's just not possible.

One option is to just publish nothing to the frontpage... so it will still be there but empty.
Logged

Say no to Internet Explorer 6.
Anastasia Kiryanova
Newbie
*
Offline Offline

Posts: 8


Re: Excluding code/scripts from pages
« Reply #8 on: July 06, 2008, 12:04:30 AM »

Hi, thanks for answer!

The problem is: I use the Popolus-template and there is some content in the mainbody-section.
You can see it at the picture blow. Between USER4/USER5 and USER6/USER7 there is a section with content (text "Module variations..."



I simply want to have this whole thing away from my site. I can delete all content, but still an empty white space will be left there.
I thought this is what James wanted to explain here or not?

Thanks a lot for help!

Anastasia
Logged
James S!
Muffin Man
RocketTheme
Hero Rocketteer
*
Offline Offline

Posts: 38324


Firebug...Firebug...Firebug!

WWW
Re: Excluding code/scripts from pages
« Reply #9 on: July 06, 2008, 07:39:30 AM »

You can disable the mainbody, quite a few people do it.
Logged

Firebug Video Tuts: - Editing HTML - Javascript Errors - Logo Changes

Video tutorials on how to use Firebug, its what we use Smiley
Anastasia Kiryanova
Newbie
*
Offline Offline

Posts: 8


Re: Excluding code/scripts from pages
« Reply #10 on: July 06, 2008, 08:25:42 AM »

Hi James!

Thanks for answer. Right, thats exactly what I want. Just still the question is... how?

I tried to modify the code as you showed above with:

Code:
<?php if ($option!="com_frontpage") : ?>
<?php mosMainbody(); ?>
<?php endif; ?>

but this does definatley not work.

Thanks,

Anastasia
« Last Edit: July 06, 2008, 09:16:38 AM by Anastasia Kiryanova » Logged
James S!
Muffin Man
RocketTheme
Hero Rocketteer
*
Offline Offline

Posts: 38324


Firebug...Firebug...Firebug!

WWW
Re: Excluding code/scripts from pages
« Reply #11 on: July 07, 2008, 02:30:24 AM »

Are you using Joomla 1.5?
Logged

Firebug Video Tuts: - Editing HTML - Javascript Errors - Logo Changes

Video tutorials on how to use Firebug, its what we use Smiley
Anastasia Kiryanova
Newbie
*
Offline Offline

Posts: 8


Re: Excluding code/scripts from pages
« Reply #12 on: July 07, 2008, 03:26:25 AM »

Hi James!

No, 1.0.14

thanks!

Anastasia

/// 08.07.2008 ///

Guys, does anybody have a solution for this? Plz help, must finish the site in a few days ((

thanks!

Anastasia
« Last Edit: July 08, 2008, 04:46:34 AM by Anastasia Kiryanova » Logged
Dennis Nocom
Jr. Rocketeer
**
Offline Offline

Posts: 30


Re: Excluding code/scripts from pages
« Reply #13 on: July 09, 2008, 10:59:31 PM »

same question with me, how do you remove it?
Logged
James S!
Muffin Man
RocketTheme
Hero Rocketteer
*
Offline Offline

Posts: 38324


Firebug...Firebug...Firebug!

WWW
Re: Excluding code/scripts from pages
« Reply #14 on: July 10, 2008, 03:18:39 AM »

In your second code, you don't have any spaces like in the first instance?
Logged

Firebug Video Tuts: - Editing HTML - Javascript Errors - Logo Changes

Video tutorials on how to use Firebug, its what we use Smiley
Pages: [1] 2 3 Go Up Print 
RocketTheme  |  General  |  Free/GPL/Tutorials Discussions  |  Topic: Excluding code/scripts from pages « previous next »
Jump to: