Trying to get SCRIPT_NAME to work for parent directory.

Discussion forum for MOD Writers regarding MOD Development.
Locked
ht3k
Registered User
Posts: 8
Joined: Tue Oct 13, 2009 4:40 am

Trying to get SCRIPT_NAME to work for parent directory.

Post by ht3k »

Support Request Template
What version of phpBB are you using? phpBB 3.0.6
What is your board's URL? N/A
Who do you host your board with? Testing Server ATM
How did you install your board? I used the download package from phpBB.com
Is your board a fresh install or a conversion? Fresh Install
Do you have any MODs installed? No
Is registration required to reproduce this issue? No
What styles do you currently have installed? Burnerz
What language(s) is your board currently using? PHP
Which database type/version are you using? MySQL 5
What is your level of experience? Comfortable with PHP and phpBB
When did your problem begin? Not really a problem... [below]
Please describe your problem.

I've had plenty of template experience but I'm stumped on this one. I could make a simple work around but I would like to learn the right way to do this. I'm trying to get tabs to work for custom files that are outside the /forum/ directory where PHPBB is. (I would like to keep them separate from the phpbb folder for many reasons.)


<li<!-- IF SCRIPT_NAME == 'index' or SCRIPT_NAME == 'viewforum' or SCRIPT_NAME == 'viewtopic' --> class="activetab"<!-- ENDIF -->


Current folders:

[root]
/forums/index.php
/custompages/index.php
/miscfolder
/etc


In other words if I'm not mistaken the tabs won't work if they don't detect a page inside the /forums/ folder. There's no way to detect the page outside the PHPBB folder unless I create something like PAR_SCRIPT_NAME and modify it accordingly. I looked through the source and yeah I pretty much have no idea where to start. If anyone could guide me to where I could create a duplicate SCRIPT_NAME for a parent folder outside PHPBB for the folder /custompages/index.php I would greatly appreciate it. Thank you for your time and I hope I was able to explain myself well.


Generated by SRT Generator ($Rev: 3603 $)

ht3k
Registered User
Posts: 8
Joined: Tue Oct 13, 2009 4:40 am

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by ht3k »

Suggestions anyone? :D

User avatar
tbackoff
Former Team Member
Posts: 7022
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by tbackoff »

Try

Code: Select all

<li<!-- IF SCRIPT_NAME == './custompages/index' --> class="activetab"<!-- ENDIF -->
To be honest, I can't remember if it's one period or two to go "up" one directory, so try both ways.
Flying is the second best thrill to cheerleaders; being caught is the first.

User avatar
Nelsaidi
Registered User
Posts: 525
Joined: Mon Feb 11, 2008 1:59 pm
Location: London, UK
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by Nelsaidi »

Try putting {SCRIPT_NAME} in your HTML template somewhere, and taking a look at what its set to, and then using that figure what you need to do.
Image
Click here to find out what eRepublik is.

ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by ChaosBringer »

The Script_name is defined in sessions.php

Code: Select all

function extract_current_page($root_path)
 

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001

User avatar
imkingdavid
Former Team Member
Posts: 2667
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by imkingdavid »

As was already suggested, but try and place the script name in the template somewhere to see what it is outputting. Then come back and let us know if you can't figure out how to use it. :)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
FreakyBlue
Registered User
Posts: 331
Joined: Sun Jul 27, 2008 6:00 pm
Name: David Jansen
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by FreakyBlue »

I'm interested if someone has an answer to the question above. Cause I'm looking for a solution too.
I've got two MODs in development and one is stored in the folder './downloadcentre/
The main file in that folder is index.php

When you visit the downloadcentre at the board the menu button downloadcentre is set to active, but also the main board index button. Both use an index.php file.

Doing something like SCRIPT_NAME == 'downloadcentre/index' doesn't work.

When I use the {SCRIPT_NAME} it spits out 'index' for both. So I'm wondering, can this be done?
My music and tutorials -> https://youtube.com/gh0stwrit3rMusic/
Former phpBB Style and Mod Author -> https://www.phpbb.com/customise/db/auth ... tributions

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51931
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by Brf »

That is because SCRIPT_NAME comes from page['page_name'] which is only the filename.
You could build your own from page['page_dir'] or something.

User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by stickerboy »

A simpler way, might be to set something like:

Code: Select all

		'S_IS_CUSTOM_PAGE'			=> true,
On you custom page, then make your template switch

Code: Select all

<li<!-- IF S_IS_CUSTOM_PAGE --> class="activetab"<!-- ENDIF -->
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red

User avatar
FreakyBlue
Registered User
Posts: 331
Joined: Sun Jul 27, 2008 6:00 pm
Name: David Jansen
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by FreakyBlue »

That doesn't do it, because it won't disable the SCRIPT_NAME == 'index' in the navigation menu that's defined for the board index.

I'll give an example. This part controls my navigation menu and it's called in the overall_header.html

Code: Select all

<div id="menubar">
	<div id="wrap">
		<ul id="menubar">
    	<li <!-- IF SCRIPT_NAME == 'index' or SCRIPT_NAME == 'viewforum' or SCRIPT_NAME == 'viewtopic' or SCRIPT_NAME == 'viewonline' or SCRIPT_NAME == 'ucp' or SCRIPT_NAME == 'mcp'   --> class="chosen" <!-- ENDIF -->><a href="{U_INDEX}">{L_INDEX}</a></li>
		<li <!-- IF SCRIPT_NAME == 'linkpage' --> class="chosen" <!-- ENDIF -->><a href="{U_LINKPAGE}" title="{L_LINKPAGE}">{L_LINKPAGE}</a></li>
            <li <!-- IF S_IS_CUSTOM_PAGE --> class="chosen" <!-- ENDIF -->><a href="{U_DOWNLOADCENTRE}" title="{L_DOWNLOADCENTRE}">{L_DOWNLOADCENTRE}</a></li>
   		</ul>
	</div>
</div>
Ofcourse it can be done to make a single 'overall_header' for the custom page in which you only apply the 'chosen tab' to the custom page. That works. But that also means you have to edit two files if you want to change your main navigation (meaning two overall_headers or in my example two navigation_menu files because I include them).
Brf wrote:That is because SCRIPT_NAME comes from page['page_name'] which is only the filename.
You could build your own from page['page_dir'] or something.
And how can this be done? Could you give me a little clue?
My music and tutorials -> https://youtube.com/gh0stwrit3rMusic/
Former phpBB Style and Mod Author -> https://www.phpbb.com/customise/db/auth ... tributions

User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by stickerboy »

Well, you could either remove the SCRIPT_NAME == 'index' and set a S_FORUM_INDEX => true, which should work. Playing around (as i'm working on some other things just now) and I found that this works rather nicely :)

Code: Select all

basename(dirname($_SERVER['SCRIPT_NAME'])) 
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red

User avatar
FreakyBlue
Registered User
Posts: 331
Joined: Sun Jul 27, 2008 6:00 pm
Name: David Jansen
Contact:

Re: Trying to get SCRIPT_NAME to work for parent directory.

Post by FreakyBlue »

I've figured it out what you mean with the code. But still both tabs are active. I'm little bit tired at this moment ... sitting to long behind my comp. Tomorrow, after a good night sleep, I will try to figure it out some more.
My music and tutorials -> https://youtube.com/gh0stwrit3rMusic/
Former phpBB Style and Mod Author -> https://www.phpbb.com/customise/db/auth ... tributions

Locked

Return to “[3.0.x] MOD Writers Discussion”