Oh, and is there any way to show all my array cells If I don't know which size is the array?
Edited: I suspect that it is done in this way. Code:
<vb:each from="my_array" key="key1" value="my_result"> resource(46) of type (mysql result) And each row is: Code:
array(21) { ["id"]=> string(2) "18" ["name"]=> string(5) "ABRIR" ["description"]=> string(23) "Iniciar la interacci?n." ["userid"]=> string(4) "2858" ["username"]=> string(20) "Seducci?n Cient?fica" ["dateline"]=> string(10) "1311875182" ["lastupdate"]=> string(10) "1311933838" ["categoryid"]=> string(1) "1" ["status"]=> string(1) "1" ["ipaddress"]=> string(13) "81.202.205.41" ["attach"]=> string(1) "0" ["threadid"]=> string(1) "0" ["lastupdater"]=> string(20) "Seducci?n Cient?fica" ["lastupdaterid"]=> string(4) "2858" ["tags"]=> string(16) "abrir,escalada 1" ["popup"]=> string(23) "Iniciar la interacci?n." ["views"]=> string(1) "0" ["votenum"]=> string(1) "0" ["votetotal"]=> string(1) "0" ["linkurl"]=> string(7) "http://" ["banner"]=> string(7) "http://" } Code:
<vb:each from="my_query" value="sentence"> But It doesn't show nothing, as if the each is not being executed. I expected to show, at least, 46 Test words. |
Quote:
You are registering the return from one of the query functions. You need to call fetch_array() to get an array for each row, like: Code:
$results = $db->query_read("some sql"); Of course each row is an array (even if you only selected one column). If you are selecting one column from a number of matching rows, you won't get an array with all the matching values, you still get an array for each row. If you want an array with all the matching values you'd have to build that yourself. Note also that you don't *have* to register an array to your template and use vb:each - you could format your own html string in the while loop above, then just register the string. |
[QUOTE=Boofo;2287132]Try this in the parse_templates hook:
Boofo, I was working on specialized routine and trying to use some of the vb-ojects to solve my problem when I came across the code you posted here. This redirected me to the right vb routines. Thanks so much for sharing! |
I have a problem on a page. I can use the variable {vb:raw companyname} in the places of the template that I need to. However when I want to place it in my navbits which are created by the php file it just echos itself.
Code:
$navbits = construct_navbits(array('' => ' </span></li><li class="navbit"><span><a href="/">Home</a></span></li><li class="navbit"><span><a href="../hostindex.php">Web Hosting</a></span></li><li class="navbit lastnavbit"><span>{vb:raw companyname} |
Try putting $companyname in your navbits instead of {vb:raw companyname} Since it's in a single-quoted string you need to use concatenation, like:
Code:
$navbits = construct_navbits(array('' => ' </span></li><li class="navbit"><span> |
Quote:
|
Can anyone help me out what i'm doing wrong?
i'm trying to add something to the Default navbar template. (a server status for my game server) but first i'm trying out the example but i can't get it to work. This is my plugin setup. Product : vBulletin Hook location: Global_start Title: server Status execution order :5 Plugin code: Code:
/* Some Code, setting variables, (multidimensional) array */ Code:
{vb:raw my_var} Code:
<p>{vb:raw my_var}</p> Edit: and Enable Plugin/Hook System is enabled also |
You don't want to render the navbar template because the vbulletin code already does that for you. To get your variable registered to that template you want to use preRegister, like;
Code:
$my_var = "abc"; |
Thanks a lot. :up:
Now i can start creating my plugin understanding the preRegister. |
Quote:
I'm doing this using $GLOBALS[templatevalues] = $templatevalues; rather than preRegister(). Code:
$templater = vB_Template::create('layout_start'); Then use this in the templates where you want the output to appear: Code:
{vb:raw GLOBALS.templatevalues.start_insertvar} |
All times are GMT. The time now is 07:06 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|