Page 1 of 1

Need help building an "else if" statement.

Posted: Sun Jan 25, 2009 2:38 pm
by rawoody
Let me start with saying I'm a novice when it comes to writing PHP. I have a dilemma that I'm sure I can solve if I can figure out how to write an "exception" clause, but it seems to be beyond me to figure this out, and I'm embarrassed to say I'm sure it's simple.

Here's my issue - I am working on a site for a charity. They purchased a template that is really complex for their CMS. Now I'm very experienced building my own templates and doing basic code, but the author's have introduced a ton of what I call over kill when building this template. They have a java script that was written to control the content of the site's layout. As is typical from my experience, these designers create these templates without taking into consideration how these application work in "real time". Anytime dynamic content is introduced, it cuts off part of the content.

The original script is a javascript seen here (I'm not looking to rewrite the javascript, so please bear with me here)

Code: Select all

    <script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/templates/<?php echo $mainframe->getTemplate(); ?>/js/roksameheight.js"></script>
 
Now, when a component with dynamic content (this is Joomla if anyone is familiar) comes into play, the content at the bottom is cutoff, so I tried the following code to create an exception.

Code: Select all

<?php if ($option != "com_comprofiler") : ?>&nbsp; &nbsp;
    <script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/templates/<?php echo $mainframe->getTemplate(); ?>/js/roksameheight.js"></script>
<?php endif; ?>
Now that works perfect to get the dynamic content to lay correctly in this particular component; however it breaks the template, as all it is really doing is disabling the script entirely. :oops:

What I'm looking for is a PHP statement that states use this script "unless" com_profiler (or whatever component is listed (I have three that are broken due to this script) is being used. Right now my script just disables it through out the template and my right column is a disaster. What I really need "I think" (remember novice here) is a case statement where I can include all three components. com_profiler, com_chronoforms, com_wrapper.

I'm obviously over my head here and really need an expert.

Thank you in advance for any assistance you can offer.

Ruth

Re: Need help building an "else if" statement.

Posted: Sun Jan 25, 2009 3:11 pm
by rawoody
I've made a change to the code a bit, which has helped quite a bit. Apparently (remember not the shinest spoon in the drawer here..LOL) I made an error which was disabling the code entirely. My correction has the template correct on the other pages and disables the code on the one module.

my "corrected" code

Code: Select all

<?php if ($option != "com_comprofiler") : ?>
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/templates/<?php echo $mainframe->getTemplate(); ?>/js/roksameheight.js"></script>
<?php endif; ?>
Now, how can I re-write this where I can add additional exceptions? I've been playing with switch statements, but I can't seem come up the correct code, but at least I'm closer!

Ruth