Click to See Complete Forum and Search --> : Showing div content only on certain pages


Pulsator
05-16-2008, 03:09 AM
Hi

I need to hide a div on all but the home page of a new site I am creating.

Basically, I have a div which contains a javascript news ticker. I need to have the news ticker show on the homepage of the site but to be hidden on every other page - client request.

The site is being developed in Joomla and as the div is in index.php this is currently displayed no matter which page you are viewing.

Any help would be appreciated as it's not something I've had to do before.

Thanks

M

ray326
05-16-2008, 11:04 PM
Does the div have an ID? You could style it based on a combination of its ID and an ID on the body tag of the home page.

Pulsator
05-17-2008, 03:57 AM
Hi

I am currently working on a local test server but I could upload a temp site version so you can see what I'm talking about. Would this help?

The div does have an id, however,the way Joomla works is to recall the same index.php with switches to load the relevant information. If it was a normal site I could just exclude the div from the other pages.

Ideally, what I would like is some sort of script that does something like the following:
1) Obtain page title
2) If page title is not equal to homepage title, change the status of the newsticker div to display: none; or equivilent function.

It would be good if the If statement could have multiple value comparisons as I get the sneaking feeling the client will come back to say, oh could we also have it on this page, so possibly an if else if type of arrangement might be needed, or, an array with statements that can be added, like the news ticker itself.

Would the script need to have a check for re-enabling the news ticker on the home page if it has been hidden by loading another page?

Does this make sense?

Is it possible?

Thanks

liccy
05-17-2008, 10:03 AM
If I was you I will try to find a unique ID or class that the home page have..

{ before the div that you want to hide. }

that div most be a child of something....

" A child selector matches when an element is the child of some element. A child selector is made up of two or more selectors separated by ">"."

and once you get that just display:none into the master page and in the file that is just use for the home page mark-it as display:block !important;

Other way is javascript which I really will not try to use due to SEO and web-accessibility. But the best way will be with a DOM script but you most get an id in order to use it...

You can not use it with the page title tag as far I know.

:(