0
Welcome Guest! Login
0 items Join Now

Excluding code/scripts/components from pages

  • Excluding code/scripts/components from pages

    Posted 17 years 5 months ago
    • 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
      <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
      <?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
      <?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
       
      <?php if ($option != "com_frontpage") : ?>
         <?php mosMainbody(); ?>
      <?php endif; ?>

      In Joomla 1.5:
       
      <?php if (JRequest::getVar('view') != 'frontpage') : ?>
         <jdoc:include type="component" />
      <?php endif; ?>
    • Last Edit: 16 years 7 months ago by James Spencer.
    • James Spencer / Developer & Support / Hull, UK
  • Re: Excluding code/scripts/components from pages

    Posted 17 years 6 days ago
    • 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: 17 years 6 days ago by .
  • Re: Excluding code/scripts/components from pages

    Posted 17 years 5 days ago
    • You'd use

      <?php if ($Itemid != "39") : ?>
    • James Spencer / Developer & Support / Hull, UK
  • Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • 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(' www.eventfactor.net/cms/templates/EventF...ia/music_player.html ')">
  • Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • What Joomla version are you using?
    • James Spencer / Developer & Support / Hull, UK
  • Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • 1.5
  • Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • 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:
      <div id="component-size">
      <?php mosMainbody(); ?>
      </div>

      and I changed it to
      <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
    • GollumX's Avatar
    • GollumX
    • Elite Rocketeer
    • Posts: 2817
    • Thanks: 0

    Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • 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.
    • Say no to Internet Explorer 6.
      twitter.com/mark_up
  • Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • 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..."

      This image is hidden for guests.
      Please log in or register to see it.


      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
  • Re: Excluding code/scripts/components from pages

    Posted 16 years 10 months ago
    • You can disable the mainbody, quite a few people do it.
    • James Spencer / Developer & Support / Hull, UK

Time to create page: 0.097 seconds