Jump to content

[RESOLVED] how can i check what page is open in php


GaVrA

Recommended Posts

I started making headers and footers "dynamically created" via php. that means that same html is used for every page. just like in ipb.

 

now, i usually make headers with tabs that have different background on hover. that hover image is also background image for current page, the page that user is watching atm.

 

that is very easy to accomplish with css when you have more then 1 page. like when i create some web site with 5 pages, then i would have 5 different pages to work with, and it is very easy to accomplish that "current page" effect.

 

but now that i am starting to learn and using php more then ever, i would love to know if there is some way to do this in that 1 header.php file that dynamically creates header for all my pages.

 

something like this:

 

	<div id="header_navigation">
	<ul>
		<li <if="1st page opened">class="current_page"</if> ><a title="Vratite se na početnu stranu" href="http://www.crtaci.info/">Početna</a></li>
		<li <if="2nd page opened">class="current_page"</if> ><a title="Pravila foruma" href="{$this->ipsclass->base_url}act=announce&id=2">Pravila</a></li>
		<li <if="3rd page opened">class="current_page"</if> ><a title="Download" href="http://download.crtaci.info/">Download</a></li>
		<li <if="4th page opened">class="current_page"</if> ><a title="Dnevna doza stripova!" href="http://stripovi.crtaci.info/">Stripovi</a></li>
		<li <if="6th page opened">class="current_page"</if> ><a title="Fanzin crtaci.info foruma" href="http://www.crtaci.info/index.php?autocom=fanzin">Fanzin</a></li>
		<li <if="7th page opened">class="current_page"</if> ><a title="Imate pitanje? Kontaktirajte nas!" href="http://kontakt.crtaci.info/">Kontakt</a></li>
	</ul>
</div>

 

ofc i would need this for my ipb forum also... :) or maybe there is some easyer way to do this?

Link to comment
Share on other sites


  • Management
If you tell me how pages are defined I can tell you how to check in which page you are or you mean that you want to check IPB pages from that external header file? (I'm still a bit sleepy lol)
Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


I want to use this:

 

http://www.gmarwaha.com/blog/category/client-side/jquery/

 

but i dont know how to make that background show on coresponding link, eg if board index is opened i want background to be on "Početna", if download page is opened i want "Download" in nav menu to be with background.

 

You can check my nav menu on my site... ;)

 

* Početna

* Pravila

* Download

* Stripovi

* Fanzin

* Kontakt

Link to comment
Share on other sites


  • Management

Gosh I have jQuery! I've spent so much time to learn prototype that I don't want to learn also jQuery for now xD

 

There is really no need to use Javascript for that, you can sort out the CSS PHP side but I need to know exactly which code you have in your header.php. If you can't post it there on the public board just PM me the file :)

Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


Hmm i am talking about my IPB forum... :) You can see "nav menu" html code in 1st post, the effect i want in my previus post.

 

I can implement this as it is shown on that link, but that would make background show always on "Home" tab(just like on that link)...

 

Also i dont know how to add href value for every link if i have to use it like this href="#"...

 

<ul class="lavaLamp">
		<li><a href="#">Home</a></li>
		<li><a href="#">Plant a tree</a></li>
		<li><a href="#">Travel</a></li>
		<li><a href="#">Ride an elephant</a></li>
	</ul>

Link to comment
Share on other sites


  • Management

Err no, what I was saying is that you can do it already in your PHP files without adding JS.

 

If you post here your whole header.php I can write the needed code for you :)

Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


Forget about header.php :) lets say i only need this for IPB forum where i dont use header.php :) my site is crtaci.info

 

my navigation menu is this:

 

* Početna

* Pravila

* Download

* Stripovi

* Fanzin

* Kontakt

 

html for that is this:

 

	<div id="header_navigation">
	<ul>
		<li><a title="Vratite se na početnu stranu" href="http://www.crtaci.info/">Početna</a></li>
		<li><a title="Pravila foruma" href="{$this->ipsclass->base_url}act=announce&id=2">Pravila</a></li>
		<li><a title="Download" href="http://download.crtaci.info/">Download</a></li>
		<li><a title="Dnevna doza stripova!" href="http://stripovi.crtaci.info/">Stripovi</a></li>
		<li><a title="Fanzin crtaci.info foruma" href="http://www.crtaci.info/index.php?autocom=fanzin">Fanzin</a></li>
		<li><a title="Imate pitanje? Kontaktirajte nas!" href="http://kontakt.crtaci.info/">Kontakt</a></li>
	</ul>
</div>

Edited by GaVrA
Link to comment
Share on other sites


  • Management

Well then you can use something like that:

	<div id="header_navigation">
	<ul>
		<li<if="$this->ipsclass->input['act'] == 'idx'"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Vratite se na početnu stranu" href="http://www.crtaci.info/">Početna</a></li>
		<li<if="$this->ipsclass->input['act'] == 'announce' && $this->ipsclass->input['id'] == 2"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Pravila foruma" href="{$this->ipsclass->base_url}act=announce&id=2">Pravila</a></li>
		<li<if="$this->ipsclass->input['autocom'] == 'downloads'"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Download" href="http://download.crtaci.info/">Download</a></li>
		<li<if="$this->ipsclass->input['autocom'] == '???'"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Dnevna doza stripova!" href="http://stripovi.crtaci.info/">Stripovi</a></li>
		<li<if="$this->ipsclass->input['autocom'] == 'fanzin'"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Fanzin crtaci.info foruma" href="http://www.crtaci.info/index.php?autocom=fanzin">Fanzin</a></li>
		<li<if="$this->ipsclass->input['autocom'] == 'contact'"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Imate pitanje? Kontaktirajte nas!" href="http://kontakt.crtaci.info/">Kontakt</a></li>
	</ul>
</div>

 

 

I'm not sure which code uses the subdomain stripovi anyway so I put ??? instead, if you tell me the real link I'll adjust it :)

Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


  • Management

Change:

<li<if="$this->ipsclass->input['autocom'] == 'downloads'"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Download" href="http://download.crtaci.info/">Download</a></li>

With:

<li<if="$this->ipsclass->input['act'] == 'sf' && $this->ipsclass->input['f'] == 84"> class="YOUR_ACTIVE_TAB_CLASS_HERE"</if>><a title="Download" href="http://download.crtaci.info/">Download</a></li>

Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


  • Management

The issue/request this topic was opened for has now been resolved. If you need further assistance, please open a new topic.

 

If this topic was closed prematurely, please contact me so I can re-open it. :)

 

 

Topic Closed

Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.