Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2006, 08:50 AM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Variable Value Incorrect, why?

See this script: http://www.vbhackers.com/testportal.php

Why is the variable $vbulletin->sitenews['newstitle'] not showing the correct information?
Reply With Quote
  #2  
Old 01-31-2006, 09:45 AM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
// table prefix fix

$PortalNews = $vbulletin->db->query_first("
        SELECT " . TABLE_PREFIX . "thread.*, post.pagetext AS pagetext
        FROM " . TABLE_PREFIX . "thread
        LEFT JOIN " . TABLE_PREFIX . "post AS post
        ON(post.postid = " . TABLE_PREFIX . "thread.firstpostid)
        WHERE forumid = 2
        ORDER BY dateline DESC
");

// or however you want to do it
Code:
// make an array

if (is_array($vbulletin->sitenews))
{
        echo " Yes, an array. ";
}
else
{
        echo " No, not array. ";
}

$vbulletin->sitenews = unserialize($vbulletin->sitenews);

echo $vbulletin->sitenews['newstitle'];

// check out $unserialize and function register in class core
Reply With Quote
  #3  
Old 01-31-2006, 09:56 AM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Worked perfect. Thanks man. Quick question for you though.

PHP Code:
if (is_array($vbulletin->sitenews))
{
        echo 
" Yes, an array. ";
}
else
{
        echo 
" No, not array. ";

Whats the purpose of that? Seemes that

PHP Code:
$vbulletin->sitenews unserialize($vbulletin->sitenews);
echo 
$vbulletin->sitenews['newstitle']; 
Works..
Reply With Quote
  #4  
Old 01-31-2006, 09:59 AM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It has no purpose other than to echo the issue.
Reply With Quote
  #5  
Old 01-31-2006, 10:18 AM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

One last question for you Calorie. How do you greab the info from datastore when the info is an array() with 8 array()'s within that array(). If that made sense to you.

Stupid merge crap... EDITED POST.

This seemed to work for me
PHP Code:
        $test 1;
        foreach (
$vbulletin->testing AS $test => $blah)
        {
                
$test++;
                echo 
$test;

                echo 
$vbulletin->testing[$test]['title'];
        } 
Reply With Quote
  #6  
Old 01-31-2006, 10:54 AM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// build datastore after while completes

$ary = array();
$vB35HacksData $db->query_read("
    SELECT title, threadid
    FROM " 
TABLE_PREFIX "thread
    WHERE forumid = 67
    ORDER BY dateline DESC
    LIMIT 8
"
);
while (
$vB35Hacks $db->fetch_array($vB35HacksData))
{
    
$ary[] = $vB35Hacks;
}

build_datastore('testing'serialize($ary)); 
PHP Code:
// be rid of $test counter stuff

$vbulletin->testing = <<<END
a:8:{i:0;a:2:{s:5:"title";s:20:"(VB3.5)RadioBlogv1.0";s:8:"threadid";s:4:"2470";}i:1;a:2:{s:5:"title";s:22:"Limit age registration";s:8:"threadid";s:4:"2463";}i:2;a:2:{s:5:"title";s:25:"Custom Forum Status Icons";s:8:"threadid";s:4:"2440";}i:3;a:2:{s:5:"title";s:12:"Nfo2png Hack";s:8:"threadid";s:4:"2403";}i:4;a:2:{s:5:"title";s:33:"vRules - Basic Rules Modification";s:8:"threadid";s:4:"2392";}i:5;a:2:{s:5:"title";s:42:"Last10races with Mirrors For Furys FxpPack";s:8:"threadid";s:4:"2256";}i:6;a:2:{s:5:"title";s:35:"Latest Nforce Releases on forumhome";s:8:"threadid";s:4:"2185";}i:7;a:2:{s:5:"title";s:9:"Nuke hack";s:8:"threadid";s:4:"2179";}}
END;

$vbulletin->testing unserialize($vbulletin->testing);

ksort($vbulletin->testing);

foreach (
$vbulletin->testing AS $blah)
{
    echo 
$blah['title'] . "<br />";

PHP Code:
/* output ordered by key

(VB3.5)RadioBlogv1.0
Limit age registration
Custom Forum Status Icons
Nfo2png Hack
vRules - Basic Rules Modification
Last10races with Mirrors For Furys FxpPack
Latest Nforce Releases on forumhome
Nuke hack

*/ 
Reply With Quote
  #7  
Old 01-31-2006, 10:57 AM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Liked your way better. Thanks to you I now completely understand vBulletins datastore system.
Reply With Quote
  #8  
Old 01-31-2006, 11:11 AM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, your way threw an 'invalid argument supplied for foreach' error.

BTW, you don't need ksort because you're ordering by dateline in the query, dumping into $ary[], and un/serialize will keep the order.

You could dump into $ary[$threadid] and then ksort to order by the thread ID, but then there'd be no point to order by in the query.
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 04:00 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
  • Page Generation 0.07213 seconds
  • Memory Usage 2,247KB
  • 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
  • (2)bbcode_code
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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