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 05-19-2013, 06:02 AM
AndrewSimm AndrewSimm is offline
 
Join Date: Sep 2006
Location: Atlanta, GA
Posts: 222
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using {var} in php files

I need the $section1 have the value of {vb:raw entry.field97}. What I am going it showing the cms articles of a particular section in a vbdynamics page. The current code show section 1 but I need to be able to change the section for each entry which is defined in {vb:raw entry.field97}.

PHP Code:
<?php
// Set Your Section ID Here
$section1 '1';
// Set The Number of Articles To Display
$limit1 '20';

$articlegrab1 vB::$db->query_read("
SELECT "
.TABLE_PREFIX."cms_nodeinfo.nodeid
    , "
.TABLE_PREFIX."cms_nodeinfo.title
    , "
.TABLE_PREFIX."cms_article.previewtext
    , "
.TABLE_PREFIX."cms_article.pagetext
    , "
.TABLE_PREFIX."cms_article.contentid
    , "
.TABLE_PREFIX."cms_node.nodeid 
    , "
.TABLE_PREFIX."cms_node.parentnode
    , "
.TABLE_PREFIX."cms_node.contentid
    , "
.TABLE_PREFIX."cms_node.url
    , "
.TABLE_PREFIX."cms_node.publishdate
    , "
.TABLE_PREFIX."cms_node.setpublish
  FROM "
.TABLE_PREFIX."cms_article
, "
.TABLE_PREFIX."cms_nodeinfo
, "
.TABLE_PREFIX."cms_node
  WHERE ("
.TABLE_PREFIX."cms_nodeinfo.nodeid = ".TABLE_PREFIX."cms_node.nodeid)
    AND ("
.TABLE_PREFIX."cms_article.contentid = ".TABLE_PREFIX."cms_node.contentid)
    AND ("
.TABLE_PREFIX."cms_node.parentnode IN ($section1))
    AND ("
.TABLE_PREFIX."cms_node.setpublish != 0)
  ORDER BY "
.TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit1
"
);



while(
$articleinfo1 vB::$db->fetch_array($articlegrab1)) {

    
$title1 $articleinfo1['title'];
    
$text1$articleinfo1['previewtext'];
    
$nodeid1 $articleinfo1['nodeid'];
    
$url1 $articleinfo1['url'];
    
$pagetext1 $articleinfo1['pagetext'];  
    
$unixdate1 $articleinfo1['publishdate']; 
    
$date1 date("F j, Y, g:i a"$unixdate1);  
    
$fulltext1 strip_bbcode($fulltext1);
    
$text1 preg_replace('/\[ATTACH\=CONFIG\]\d\d\[\/ATTACH\]/'''$text);
    
$text1 strip_bbcode($text1);
    
$pagetext1 strip_bbcode($pagetext1);


    if(
$text1 == ''$pagetext1 substr($pagetext10120);



    
$centerhtml1 .="<div style='padding-bottom:10px;margin-bottom:10px; margin-left:8px; margin-right:8px;border-bottom:1px solid #cccccc''>";
    
$centerhtml1 .="<b><a href='/content.php?".$nodeid1."-".$url1."'>".$title1."</a></b>";
    
$centerhtml1 .="<p><span style='color:#6f6f6f'>".$date1."</span></p>";
    
$centerhtml1 .="<p>".$pagetext1."...</p></div>";

    
}
vB::$db->free_result($articlegrab1);
$tabhtml1 "<div><ul>".$tabhtml1."</ul>";
echo 
$tabhtml1.$centerhtml1."</div>";
// 
?>
Reply With Quote
  #2  
Old 05-19-2013, 12:40 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The exact meaning of {vb:raw entry.field97} depends on which template it's from. If I had to guess, I'd say you could try this:
Code:
global $entry;
$section1 = $entry['field97'];

but it's unlikely that it will work. You need to figure out where that value comes from and if it's available on your vbdynamics page (I don't know anything about vbdynamics). It's possible that the value you need hasn't even been set when your vbdynamics code runs, in which case you'd need to figure out how to get it yourself.
Reply With Quote
  #3  
Old 05-19-2013, 02:28 PM
AndrewSimm AndrewSimm is offline
 
Join Date: Sep 2006
Location: Atlanta, GA
Posts: 222
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works on my vbdynamics page but not on my php file that I am including in the page via the plugin system.

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

This is what I got when I tried it. My guess is the plugin doesnt have access to vbdynamics but I'm not sure.

Quote:
Warning: mysqli_query() [function.mysqli-query]: (42000/1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND (cms_node.setpublish != 0) ORDER BY cms_node.publishdate DESC LIMIT' at line 17 in [path]/includes/class_core.php on line 1391
Reply With Quote
  #4  
Old 05-20-2013, 04:38 PM
AndrewSimm AndrewSimm is offline
 
Join Date: Sep 2006
Location: Atlanta, GA
Posts: 222
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone else?
Reply With Quote
  #5  
Old 05-20-2013, 06:20 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AndrewSimm View Post
It works on my vbdynamics page but not on my php file that I am including in the page via the plugin system.

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

This is what I got when I tried it. My guess is the plugin doesnt have access to vbdynamics but I'm not sure.
Yeah, sorry, I couldn't really understand exactly what you're doing, so I thought I'd let someone else try. Anyway, the above error looks like what would happen if $section1 was blank. This isn't the solution to your original problem, but you might want to change the code to ensure that if $section1 is empty, it doesn't try to do the query.
Reply With Quote
  #6  
Old 05-21-2013, 05:57 AM
AndrewSimm AndrewSimm is offline
 
Join Date: Sep 2006
Location: Atlanta, GA
Posts: 222
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Yeah, sorry, I couldn't really understand exactly what you're doing, so I thought I'd let someone else try. Anyway, the above error looks like what would happen if $section1 was blank. This isn't the solution to your original problem, but you might want to change the code to ensure that if $section1 is empty, it doesn't try to do the query.
Good idea, I set it so that if($section1 == '') it display a message, else it executes the rest of the code.

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

In my template I would use {vb:raw entry.field97} to display that field. This doesnt work in my php file, just the template where everything is displayed.

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

Ok so when I just use the php in the plugin it works but puts it at the top of my page. When I put the php in a separate file then it doesnt work. Currently It is display what I want but at the very top of the page inside of the div. I guess that is because it is just firing it on page load instead of when it reaches the spot in the html

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

This worked, once I add in category I am done. kh99 thank you.
PHP Code:
ob_start(); 

// Set Your Section ID Here
global $entry;
$section1 $entry['field97'];
// Set The Number of Articles To Display
$limit1 '20';

if(
$section1 == ''
{
echo 
"<span style='margin-left:8px;'>There is no news for this recruit</span>";
}
else
{

$articlegrab1 vB::$db->query_read("
SELECT "
.TABLE_PREFIX."cms_nodeinfo.nodeid
    , "
.TABLE_PREFIX."cms_nodeinfo.title
    , "
.TABLE_PREFIX."cms_article.previewtext
    , "
.TABLE_PREFIX."cms_article.pagetext
    , "
.TABLE_PREFIX."cms_article.contentid
    , "
.TABLE_PREFIX."cms_node.nodeid 
    , "
.TABLE_PREFIX."cms_node.parentnode
    , "
.TABLE_PREFIX."cms_node.contentid
    , "
.TABLE_PREFIX."cms_node.url
    , "
.TABLE_PREFIX."cms_node.publishdate
    , "
.TABLE_PREFIX."cms_node.setpublish
  FROM "
.TABLE_PREFIX."cms_article
, "
.TABLE_PREFIX."cms_nodeinfo
, "
.TABLE_PREFIX."cms_node
  WHERE ("
.TABLE_PREFIX."cms_nodeinfo.nodeid = ".TABLE_PREFIX."cms_node.nodeid)
    AND ("
.TABLE_PREFIX."cms_article.contentid = ".TABLE_PREFIX."cms_node.contentid)
    AND ("
.TABLE_PREFIX."cms_node.parentnode IN ($section1))
    AND ("
.TABLE_PREFIX."cms_node.setpublish != 0)
  ORDER BY "
.TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit1
"
);



while(
$articleinfo1 vB::$db->fetch_array($articlegrab1)) {

    
$title1 $articleinfo1['title'];
    
$text1$articleinfo1['previewtext'];
    
$nodeid1 $articleinfo1['nodeid'];
    
$url1 $articleinfo1['url'];
    
$pagetext1 $articleinfo1['pagetext'];  
    
$unixdate1 $articleinfo1['publishdate']; 
    
$date1 date("F j, Y, g:i a"$unixdate1);  
    
$fulltext1 strip_bbcode($fulltext1);
    
$text1 preg_replace('/\[ATTACH\=CONFIG\]\d\d\[\/ATTACH\]/'''$text);
    
$text1 strip_bbcode($text1);
    
$pagetext1 strip_bbcode($pagetext1);


    if(
$text1 == ''$pagetext1 substr($pagetext10120);



    
$centerhtml1 .="<div style='padding-bottom:10px;margin-bottom:10px; margin-left:8px; margin-right:8px;border-bottom:1px solid #cccccc''>";
    
$centerhtml1 .="<b><a href='/content.php?".$nodeid1."-".$url1."'>".$title1."</a></b>";
    
$centerhtml1 .="<p><span style='color:#6f6f6f'>".$date1."</span></p>";
    
$centerhtml1 .="<p>".$pagetext1."...</p></div>";

    
}
vB::$db->free_result($articlegrab1);
$tabhtml1 "<div><ul>".$tabhtml1."</ul>";
echo 
$tabhtml1.$centerhtml1."</div>";
// 

}
$recruitnews ob_get_contents(); 
ob_end_clean();  
vB_Template::preRegister('ADV_DYNA_SHOWENTRY',array('recruitnews' => $recruitnews)); 
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 09:08 PM.


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.03968 seconds
  • Memory Usage 2,278KB
  • 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
  • (1)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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