Help - Search - Members - Calendar
Full Version: php question
Movable Type Community Forum > Additional Resources > Tips and Tricks
bill3555
I am using the technique detailed on A List Apart to update my css menu; that means, the current section of my site is highlighted on the menu.

Here's the issue: I don't know anything about php and I have a problem. So the php code knows what section it is in, at the top of the html this is declared:
CODE
<?php $thisPage="About Us"; ?>
<html><head>

But using MT and templates, this starts to get tricky when trying to run a whole site through MT--not just the blog.

Is there a php code that I can use that will replace the 'thisPage' statement, and that will define the page as the name of the directory from which the page is being called from? For example, if the page comes from website.com/photos/, then thisPage is automatically defined as 'photos'.

Of course, if someone has a more elegant or simple solution, that would be welcomed too.

Thanks.
Bill
drouse
If you have each section of the site setup in MT as a separate blog then you can use the MTBlogID or MTBlogName to label each page of that blog.

So...

CODE
<?php $thisPage="<$MTBlogID$>"; ?>


If each section of the site is a MT category archive (which would be kind of odd), then you should be able to use MTArchiveTitle to label at least the main page of each section.

I'm not sure how you would handle individual archives, then, if you had them.
bill3555
drouse, you're a peach!

Thanks for tweaking my brain, you put me on the right track. Here's what I did, for those who are interested. My static content is indeed on another blog, with each section divided using categories, as Brad Choate describes on his site.

So, to create the thisPage call, I simply added this tag:
CODE
<?php $thisPage="<$MTEntryCategory$>"; ?>

That was it. That idea has also solved some other problems that I was having. Again, thanks!
drouse
Glad I could help.

It certainly can be difficult to keep all those tags in mind when setting up a site. I had forgotten that little individual archive category tag, even though I had used it elsewhere.

And thanks for the BC link, it looks like I might have been doing things the hard way on parts of my site.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.