PDA

View Full Version : Mini Mods - Sections for logged in users in GTCustom Pages


hamidof
08-04-2007, 10:00 PM
This mod modifies GTCustom Pages, you can download it here:
https://vborg.vbsupport.ru/showthread.php?t=108583

More information here:
https://vborg.vbsupport.ru/showthread.php?t=108586

I was working on a quick project and there was 3 buy now buttons that needed to show up only for members who are logged in.
With a little modification to this hack you can do this:

First find or download goto.php that comes with this package and open it with your favourite text editor.
Find:

/*
* *************************************
* PHRASES - no need to parse
* **************************************
*/
$vbphrase['content'] = $vbphrase['gtcustom_' . $section];
$vbphrase['header_title'] = $vbphrase['gtcustom_' . $section . '_header'];
$vbphrase['sub_title'] = $vbphrase['gtcustom_' . $section . '_subtitle'];


It starts at line: 70
Add these lines after them:


/**
* User logged in stuff
* By Codehead @ talk.code-head.com
**/
if( isset($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) && strlen($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) > 0 && !$vbulletin->userinfo['userid'] ) {
$regex = '#__START_USER_SECTION__.*?__END_USER_SECTION__#is ';
$vbphrase['content'] = preg_replace($regex, $vbphrase['gtcustom_' .$section .'_user_not_logged_in'], $vbphrase['content']);
} else {
$regex = array('#__START_USER_SECTION__#i', '#__END_USER_SECTION__#i');
$vbphrase['content'] = preg_replace($regex, '', $vbphrase['content']);
}


So all together it will look like this:

/*
* *************************************
* PHRASES - no need to parse
* **************************************
*/
$vbphrase['content'] = $vbphrase['gtcustom_' . $section];
$vbphrase['header_title'] = $vbphrase['gtcustom_' . $section . '_header'];
$vbphrase['sub_title'] = $vbphrase['gtcustom_' . $section . '_subtitle'];

/**
* User logged in stuff
* By Codehead @ talk.code-head.com
**/
if( isset($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) && strlen($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) > 0 && !$vbulletin->userinfo['userid'] ) {
$regex = '#__START_USER_SECTION__.*?__END_USER_SECTION__#is ';
$vbphrase['content'] = preg_replace($regex, $vbphrase['gtcustom_' .$section .'_user_not_logged_in'], $vbphrase['content']);
} else {
$regex = array('#__START_USER_SECTION__#i', '#__END_USER_SECTION__#i');
$vbphrase['content'] = preg_replace($regex, '', $vbphrase['content']);
}


Upload it back to your server.

Then you need another phrase called:
gtcustom_YOUR_CUSTOM_PAGE_user_not_logged_in

And put the text for when the user is not logged in or not a memeber, for instance:
(HTML alowed)


You must be logged in to purchase this item.<br />
Please take a moment to login or register.


Then in your gtcustom_YOUR_CUSTOM_PAGE phrase wrap the sections in __START_USER_SECTION__ & __END_USER_SECTION__ for instance:


Some info about the item that you want to sell...
__START_USER_SECTION__
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
...
</form>
__END_USER_SECTION__

Some other item info...
__START_USER_SECTION__
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
...
</form>
__END_USER_SECTION__


You can have multiple sections for logged in users and if they are not logged in, the text in gtcustom_YOUR_CUSTOM_PAGE_user_not_logged_in will be shown.

radarhunter
08-05-2007, 01:57 PM
<font color="Red">*Reserved*</font>

Deepdog009
08-05-2007, 02:14 PM
I've recently dabbled in the custom page realm and I think this may assist me a bit here and there...

Time & Effort on this deserves a click and vote... :)

P.S ....>>> screenshots with your additions?

beduino
08-05-2007, 02:30 PM
tks for share!
all the best
beduino

rooban12
08-05-2007, 08:18 PM
thanks a lot ----- need screen shots

Forumi Shqiptar
08-14-2007, 06:37 PM
screenshots will be nice please