vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Conditonal Help (https://vborg.vbsupport.ru/showthread.php?t=150266)

Xplorer4x4 06-21-2007 10:09 AM

Conditonal Help
 
I am trying to create a conditional to use for the thread prefix hack. I would use two prefixes, one called members and one called guests. If the prefix is guest, i want guests to get a pop up asking them to register, or be redirected to the register.php.

If your familiar with the prefix hack you know the prefix itself can not have HTML mark up, you have to put it in the prefix HTML mark up box ( see screen shot here)

So what kind of mark up could I use?


I got as far as something like

<if condition="({1} == guest (then) $bbuserinfo, 1")><else><if condition="({1} == Members (then) !$bbuserinfo, 1")>

I know that is slopy and i could not think of the proper conditional to use for then, so atleast I tried. If some one could clean that up much appreciated.

TheMilkCarton 06-21-2007 10:27 AM

I'd say the easiest way would be to just edit the appropriate Thread Prefix plugins. There are 7 "Display Prefix" plugins for each location it shows the Thread Prefix in though.. :)

For example in "Prefix: Display Prefix in Front of Title (Thread)" plugin you could change
PHP Code:

if ($forum['allowprefix'] AND $thread['threadprefix'])
{
    
$thread['title'] = $vbulletin->options['prefixmarkup_start'] . $thread['threadprefix'] . $vbulletin->options['prefixmarkup_end'] . $thread['title'];


to
PHP Code:

if ($forum['allowprefix'] AND $thread['threadprefix'] AND $show['member'])
{
    
$thread['title'] = $vbulletin->options['prefixmarkup_start'] . $thread['threadprefix'] . $vbulletin->options['prefixmarkup_end'] . $thread['title'];
}
else {
echo 
"<script language=\"JavaScript\">\n";
echo 
"alert("Please register to view thread prefixes!");\n";
echo 
"</script>"


Or something.. Haha. I'm not exactly a pro at this stuff though, so I might not be doing it right. Maybe give that a try though!

EDIT: Thinking about it.. I realized this would print the error for every thread prefix that should be on the page though. Might want to insert it somewhere else? :)

EDIT #2: Although I guess if you would try doing it your way by inserting it into the Prefix Markup box, it would be executing the code for every instance of the thread prefix, too. lol.

EDIT #3: I just realized the plugin in my example was for SHOWTHREAD... not FORUMDISPLAY. lol. I need to lay off the caffeine. The right plugin might be "Prefix: Generate Prefix List (Forumdisplay)"

Xplorer4x4 06-22-2007 07:37 AM

One thing i notice is in your code there is no checks to make the prefixes see weather a person is a guest or a member.

TheMilkCarton 06-22-2007 07:40 AM

Check the first line. :)

I'm not saying that will work (since that's not even the right plugin) but I was just using *any* Thread Prefix plugin to get the point across. I didn't exactly spend a lot of time thinking about it. haha. :)

Xplorer4x4 06-22-2007 08:00 AM

I was told this can all be done via the HTML mark up so I think your code is going to deep in the first place.

This cant be to complicated but what about something like
PHP Code:

<if condition="$show['threadprefix'] = [Guests]">
<else>
<if 
condition="$show['threadprefix'] = [Members]" AND !$bbuserinfo[userid]>Members and pop up code</if> 


TheMilkCarton 06-22-2007 09:55 AM

Well, what I was trying to explain is that if you were to use a JavaScript alert in the Prefix Markup, it's going to be executing it for every prefix on the page. I don't think 20 popups will be very user friendly? I can't be certain this will happen as I don't know the ins and outs of the code, but I'd say it's more than likely.

Alternately, you could try:
Code:

<if condition="$show['member']">{1}<else /><a href="register.php$session[sessionurl_q]" rel="nofollow">$vbphrase[register]</a></if>
I'm honestly not sure if the link will parse correctly, so you could also just do this:
Code:

<if condition="$show['member']">{1}<else />Register to View</if>

EDIT:
I think you're going to have to alter the plugins. Sorry. It didn't know what to do with the variables I used, so they'd need to be added into the plugin anyway.. OR whoever said conditionals would work in that markup box was wrong. :( Sorry.


All times are GMT. The time now is 10:02 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01141 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete