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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2008, 07:34 AM
jfk1 jfk1 is offline
 
Join Date: Mar 2008
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default create link to a forum using "title_clean" as tag?

hi, i'm new to vbull, new to php....
i am trying to define links to forums using title_clean as the identifier. (i believe this to be the only aplha unique field within table).
can anyone please point me in the right direction...
more info...
what i really want is a link to a forum which coresponds to a specific vbad page. the idea being that the vbad page is the "entry point" for visitor, which then has a link to forum which coresponds to that page. i have created tables in mysql which have identical values for "pageid" and "title_clean".
thanx in advance
jfk

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

here is an example of what i trying to achieve... tho not correct!... the link must be defined by a variable (to enable multiple entries into db)
$url/forums/forumdisplay.php?f=$foruminfo[title_clean=pageid] ... (title_clean and pageid have identical values in the db) or something like this
Reply With Quote
  #2  
Old 05-18-2008, 02:45 PM
jfk1 jfk1 is offline
 
Join Date: Mar 2008
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i see a lot of views to my post, but no replies which probably means i'm not asking the correct question.
here is what i want to do. i have created a list of vb_adv pages. i have created a list of vbul forums. both pages and forums are from the same list. i want to make a link from the "page" to the corresponding "forum" (and vice-versa) using $variable.
i know which data i want to look up, but my problem is that i dont know the syntax.
i would like vbull to look at the page it is currently displaying, using whatever $variable it used to create that page eg. sql_table "adv_pages"- field "title", then take this piece of data and go look in sql_table "forum"- field "title_clean", compare the data and return a match which then displays the relative forum.

i guess i've made this a complicated question again .... sorry.
Reply With Quote
  #3  
Old 05-19-2008, 12:57 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the best anyone can offer you is the following:

Use the following conditional in your forumdisplay template:
Code:
<if condition="$forumid == X">Your ad here</if>
Whereas X is the forum ID where you'd like the content to appear. If you'd like the same ad to appear on a number of boards, then use the following:

Code:
<if condition="in_array($forumid, array(X,Y,Z))">Your ad here</if>
Where as X Y Z refer to different forum ID's

More conditionals:

http://www.vbulletin.com/forum/showthread.php?t=200894
Reply With Quote
  #4  
Old 10-22-2008, 11:50 AM
jfk1 jfk1 is offline
 
Join Date: Mar 2008
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hello again, i'm back!
i am sure there are a number of ppl here who can solve this problem for me, if i can just attract their attention for a few mins. i am half way through my second year of vbull license, and still dont have a working forum. this must be a record!
i am member of vbulletin (obviously), vbulletin.org, vbadvanced, and vbulletinsetup, and somehow i can't seem to ask the right question.... to get the right answer. i will try a different tack here, again!
essentially, i want to "query the sql database". how hard can that be, u might ask? all over the world, vbull scripts must be "querying the database" a million times a second! the whole script "survives" on "querying the database". this is precisely why i have opted for vbull, BECAUSE it uses mysql! i am getting a little despondent, at this stage. i should by this time, be an expert in PHP, MYSQL, and any number of programming langs!
ok, enough of waffle.
why does this not work?
Code:
$get_forumid = $db->query("SELECT forumid FROM " . TABLE_PREFIX . "forum WHERE title LIKE '$getpage'");
where $get_forumid is a new $var that i want to create, $getpage is a preset $var, which i want to submit (compare) to the db, and the result (returned value of $get_forumid) i want to use here:
Code:
<a href="http://mysite.com/forums/forumdisplay.php?f="$get_forumid">
Reply With Quote
  #5  
Old 10-23-2008, 08:26 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You probably want to use $db->query_first() instead of $db->query().

also make sure that $getpage is cleaned before using it in the query.
Reply With Quote
  #6  
Old 10-25-2008, 03:52 PM
jfk1 jfk1 is offline
 
Join Date: Mar 2008
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
You probably want to use $db->query_first() instead of $db->query().

also make sure that $getpage is cleaned before using it in the query.
thanx for reply. i have tried query_first, doesnt appear to make a diference. could u possible give me an example of a "working" query..... or better still suggest a place in the script, where i could drop my query in.... i want to place a link in the navbar. thanx

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

here is an of what i have tried so far:
here's where i up to.... inserted query here (in vba_cmps_include_top.php)

Code:
// Figure out which page to grab
$pagevar = $vba_options['portal_pagevar'];

if (defined('VBA_PAGE'))
{
$getpage = VBA_PAGE;
}
else if(isset($_REQUEST[$pagevar]))
{
$getpage = $_REQUEST[$pagevar];
//jfk
$get_forumid = $db->query("SELECT forumid FROM " . TABLE_PREFIX . "forum WHERE title LIKE '$getpage'");

//end jfk
i figured this is precisely where the page name is set, therefore this is the value i need to submit to the forum table....
then i have inserted this link here (in navbar template)

Code:
<!-- nav buttons bar -->
<div class="tborder" style="padding:$stylevar[cellspacing]px; border-top-width:0px">
<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr align="center">
<!--######### jfk #############-->
<td class="vbmenu_control"><a href="$vboptions[homeurl]">$vboptions[hometitle]</a></td>
<td class="vbmenu_control"><a href="http://ntra.org.uk/forums/forumdisplay.php?f="$get_forumid">Forum</a></td>


<!--######### end jfk ######### -->
i dont get a "reported error" exactly, however when i look at sourcecode in compiled page i see "<a href="http://ntra.org.uk/forums/forumdisplay.php?f="Resource id #15">
Reply With Quote
  #7  
Old 10-28-2008, 12:36 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$get_forumid $db->query_first("SELECT forumid FROM " TABLE_PREFIX "forum WHERE title LIKE '$getpage'"); 
This will return an array with the values of the selected data (assuming this will only return a single row!!). In your templates you will need to use $get_forumid[forumid].
Reply With Quote
  #8  
Old 10-28-2008, 03:31 PM
jfk1 jfk1 is offline
 
Join Date: Mar 2008
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
PHP Code:
$get_forumid $db->query_first("SELECT forumid FROM " TABLE_PREFIX "forum WHERE title LIKE '$getpage'"); 
This will return an array with the values of the selected data (assuming this will only return a single row!!). In your templates you will need to use $get_forumid[forumid].
am i amissing a step somewhere... using $get_forumid[forumid] in the html doesnt show a value. do i need use fetch_array (to interpret db result) even though result will only be a single value... [forumid].... which is an integer.
Reply With Quote
  #9  
Old 10-29-2008, 08:40 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the value of $get_forumid after the database call?
Reply With Quote
  #10  
Old 10-29-2008, 03:54 PM
jfk1 jfk1 is offline
 
Join Date: Mar 2008
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
What is the value of $get_forumid after the database call?
i assume you are asking, what "should" be the value of $get_forumid after the database call, as this exercise is solely intended to ascertain this value (in order that i can use this value in the href). with the present code that i am using i am getting a return value (result) like this... "/forumdisplay.php?f="Resource id #15"> ". the actual value is contained within the "Resource id #15", apparently, and must be "interpreted" in order to use it in php code (or html).
the "real" expected value would be as follows: if i submit (to db) a $pagetitle var which= "Stockport", for example... the query will find a forum which also has a "title" of Stockport, and this would have a "forumid" value of "395". (this is the actual entry in the db)
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 10:10 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.04565 seconds
  • Memory Usage 2,273KB
  • 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
  • (6)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
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete