Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-11-2012, 11:25 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Order of info possible?

Is there a way to set the order in a setting for info added to an option like the following?

PHP Code:
$vbulletin->options['boofo_sucks'] .= Some info here;
$vbulletin->options['boofo_sucks'] .= Slam Boofo here;
$vbulletin->options['boofo_sucks'] .= Hit him again;
$vbulletin->options['boofo_sucks'] .= Bounce him off the floor;
$vbulletin->options['boofo_sucks'] .= Push him out the door

Now, if I want to change the order that those things get added to the option, is there a way to do that in PHP? I know switch will allow me to choose one of them but I want to be able to set the order somehow.
Reply With Quote
  #2  
Old 01-11-2012, 12:12 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Which order? You're concatenating strings... if you want to change the order, well, change the order of the lines.
Reply With Quote
  #3  
Old 01-11-2012, 12:31 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I understand that. I was just wanting to know i it was possible to do it automatically with setting.
Reply With Quote
  #4  
Old 01-11-2012, 12:35 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you elaborate a bit more detailed? I'm not quite sure I get what you want to accomplish.

Maybe use arrays instead of appends?

PHP Code:
$vbulletin->options['boofo_sucks'][] = Some info here;
$vbulletin->options['boofo_sucks'][] = Slam Boofo here;
$vbulletin->options['boofo_sucks'][] = Hit him again;
$vbulletin->options['boofo_sucks'][] = Bounce him off the floor;
$vbulletin->options['boofo_sucks'][] = Push him out the door
This way you could 'switch' 2 array fields:

PHP Code:
$tmp $vbulletin->options['boofo_sucks'][1];
$vbulletin->options['boofo_sucks'][1] = $vbulletin->options['boofo_sucks'][3];
$vbulletin->options['boofo_sucks'][3] = $tmp
And afterward append them all together:
PHP Code:
echo implode($vbulletin->options['boofo_sucks']); 
Reply With Quote
  #5  
Old 01-11-2012, 12:51 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for responding to this.

What I want to be able to do is set it so that they can be listed/added in any order the user wants. Like 1,2,3,4,5, or 4,1,3,2,5 and so on. This is going in the footer and there are only 2 hooks there that are of no use for something like this, so this is the way I have to do it for now. Since the copyright text is anchored right below the "time is now", that is a good area to be able to add things to. Does that make any sense? I'm not very good at explaining things at times.
Reply With Quote
  #6  
Old 01-11-2012, 02:30 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok now I get it.

Sadly, no there is absolutely no way to accomplish this. It's not the best method to start with, but the vb template system has always been a bit clunky imho.

If you want to make sure a certain text appears at a certain position, use extra templatehooks or guide the user how he/she can change the order by themselves.

The only thing you can force is the to be inserted text appear at the beginning or the end.

PHP Code:
$sometext .= 'this comes at the end';
$sometext 'this comes before' $sometext
obviously.

//e:

Another method would be, if you know there is already text in the template var inserted and you want to put your text at a certain position, you can split the string, place yours and convert it to a string again:

PHP Code:
$lines explode("\n"$text);
$newlines = array();
$insert_at 4;
$new_line 'my new line';
for (
$i=0$i count($lines); $i++) {
    if (
$i == $insert_at) {
        
$newlines[$i] = $new_line;
        
$i++;
    } else {
        
$newlines[$i] = $lines[$i];
    }
}
$text implode($newlines); 
Reply With Quote
  #7  
Old 01-11-2012, 02:37 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I agree. There isn't much you can do with it the way it is. I don't like doing it this way but there really is no other choice if I want to make it as automatic as possible. They will just have to live with the order I put them in unless they want to edit the plugin, I guess. Since this was mainly for my own site, I set it up to how I use it.

Thanks for verifying what I suspected, though.

--------------- Added [DATE]1326297407[/DATE] at [TIME]1326297407[/TIME] ---------------

Quote:
Originally Posted by Disasterpiece View Post
//e:

Another method would be, if you know there is already text in the template var inserted and you want to put your text at a certain position, you can split the string, place yours and convert it to a string again:

PHP Code:
$lines explode("\n"$text);
$newlines = array();
$insert_at 4;
$new_line 'my new line';
for (
$i=0$i count($lines); $i++) {
    if (
$i == $insert_at) {
        
$newlines[$i] = $new_line;
        
$i++;
    } else {
        
$newlines[$i] = $lines[$i];
    }
}
$text implode($newlines); 
But to add this to a mod for users to use wouldn't really work, would it? Since I'm adding the text to the line, I can add it in any order I want to when making the mod. But for the end user to do it, they will have to edit the plugin manually. But you mentioned earlier about adding some hooks to the template. How hard would that be to do? I've never added hooks for a mod before. Or, being it is the footer template, maybe it would be more hassle than it is worth?
Reply With Quote
  #8  
Old 01-11-2012, 06:01 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Assuming you have each item stored in a table, why not add an 'order_by' column to the table and give the user the option to number them in the order they want?

Then query the table with order by order_by and display.
Reply With Quote
  #9  
Old 01-11-2012, 06:25 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

After all it's better to let the user modify the template on their own, not with template hooks but with html, just as they want it to look like.
Reply With Quote
  #10  
Old 01-11-2012, 08:45 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
Assuming you have each item stored in a table, why not add an 'order_by' column to the table and give the user the option to number them in the order they want?

Then query the table with order by order_by and display.
Their not stored in a table. I thought of doing it that way but really didn't want to be adding a query to every page load.

Quote:
Originally Posted by Disasterpiece View Post
After all it's better to let the user modify the template on their own, not with template hooks but with html, just as they want it to look like.
I suppose I could throw it all in a template and then just hook into the copyrighttext one time instead of adding to it for each item. Thanks for the advice, sir.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:18 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.04097 seconds
  • Memory Usage 2,283KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete