The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help in writing SQL query
EDIT: Now I would like to do this in vB 3.6 (last post).
I would like to have a bit of code in the showthread.php file and showthread template to accomplish the following task: I'd like to have different information shown in the header depending on what forumid is being viewed. I've currently accomplished this in vB 3.x using <if> conditionals in the showthread tempalte, but this is making the showthread template VERY long and I've seen a few random errors since I've implemented it that I think may be attributable to the length of the showthread template. What I'd rather do is have the query pull the results of the DB depending on what forumid is being shown and pass them into the template using a variable. I'm not sure how to write the query and such. I will only have two fields in the table, forumid and content. I'd like it such that if the forumid being viewed on the showthread.php page is equal to one that is in the table it shows that defined content. If there is no match, I'd like it such that the query returned some default row from the table. If you're curious as to what I'm really trying to do, have a look at my forums. On this page, you can see the header information (which is inserted by the showthread template) has information on books for the 70-292 exam: http://www.mcseworld.com/forums/showthread.php?t=12495 On this one, it has information on books for the 70-296 exam: http://www.mcseworld.com/forums/showthread.php?t=12522 And so forth. Like I mentioned previously, this is currently being done by a rather large chunk of HTML with conditionals in the showthread template. Here is an example of that for one of the forums: PHP Code:
Thanks in advance. |
#2
|
|||
|
|||
dontpanic,
Instead of making a new table and having to JOIN the table info I just added fields to the forum TABLE. Queries To Run ( 3 ) If you have table prefixes don't forget to add it to the 'forum' in the sqls below. Code:
ALTER TABLE forum ADD usedefbk TINYINT ( 1 ) UNSIGNED NOT NULL DEFAULT '0' ALTER TABLE forum ADD bktitle VARCHAR ( 100 ) NOT NULL ALTER TABLE forum ADD bkcontent MEDIUMTEXT NOT NULL Note that I did not vb phrase the data below. Open admincp/forum.php ( 3 ) Find: ( 1 ) PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Replace Your Code Of Conditionals Relating To Forumids With Something Similar To This: Code:
<!-- book content --> <div align="center"> <center> <table class="tborder" cellpadding="0" cellspacing="$stylevar[cellspacing]" border="0" width="100%" style="border-collapse: collapse" bordercolor="#111111"> <tbody> <tr> <td class="thead" colspan="5" width="100%" align="left" valign="top"> <a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_poparticles')"><img id="collapseimg_forumhome_poparticles" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_poparticles].gif" alt="" border="0" /></a>MCSE World Recommended Reading</td> </tr> </tbody> <tbody id="collapseobj_forumhome_poparticles" style="$vbcollapse[collapseobj_forumhome_poparticles]"> <tr> <td class="alt1Active" width="100%" align="left" valign="top" colspan="5"> <span class="smallfont"><b> <if condition="$foruminfo['usedefbk']==1"> $foruminfo[bktitle] <else /> <!-- default book title goes here --> </if> </b></span></td> </tr> <tr> <td class="alt1Active" width="20%" align="center" valign="top"> <if condition="$foruminfo['usedefbk']==1"> $foruminfo[bkcontent] <else /> <!-- default book content goes here --> </if> </td> </tr> <tr> <td class="alt1Active" width="100%" align="center" valign="top" colspan="5"><div class="smallfont"> <b>Please help support MCSE World by purchasing your study materials through these links to Amazon.com.</b></div></td> </tr> </tbody> </table> </center> </div> <br> <!-- book content --> g-force2k2 |
#3
|
|||
|
|||
g-force2k2,
Thanks. I will try it out later on my test forums and let you know how it went. |
#4
|
|||
|
|||
OK, here's the final result.
IT WORKED! I did make some minor mods: My final template: Code:
<!-- Book Content --> <div align="center"> <center> <table class="tborder" cellpadding="0" cellspacing="$stylevar[cellspacing]" border="0" width="100%" style="border-collapse: collapse" bordercolor="#111111"> <tbody> <tr> <td class="thead" colspan="5" width="100%" align="left" valign="top"> <a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_poparticles')"><img id="collapseimg_forumhome_poparticles" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_poparticles].gif" alt="" border="0" /></a>MCSE World Recommended Reading</td> </tr> </tbody> <tbody id="collapseobj_forumhome_poparticles" style="$vbcollapse[collapseobj_forumhome_poparticles]"> <if condition="$foruminfo['usedefbk']== 0"> $foruminfo[bkcontent] <else /> <tr> <td class="alt1Active" width="100%" align="left" valign="top" colspan="5"> <span class="smallfont"><b>Off the beaten path.</b></span></td> </tr> <tr> <td class="alt1Active" width="20%" align="center" valign="top"> <a href="http://www.mcseworld.com/a/0321108957" target="_blank"> <img border="0" src="http://images.amazon.com/images/P/0321108957.01.MZZZZZZZ.jpg" width="111" height="140"></a></td> <td class="alt1Active" width="20%" align="center" valign="top"> <a href="http://www.mcseworld.com/a/0201746131" target="_blank"> <img border="0" src="http://images.amazon.com/images/P/0201746131.01.MZZZZZZZ.jpg" width="110" height="140"></a></td> <td class="alt1Active" width="20%" align="center" valign="top"> <a href="http://www.mcseworld.com/a/0471237124" target="_blank"> <img border="0" src="http://images.amazon.com/images/P/0471237124.01.MZZZZZZZ.jpg" width="93" height="140"></a></td> <td class="alt1Active" width="20%" align="center" valign="top"> <a href="http://www.mcseworld.com/a/0072229020" target="_blank"> <img border="0" src="http://images.amazon.com/images/P/0072229020.01.MZZZZZZZ.jpg" width="113" height="140"></a></td> <td class="alt1Active" width="20%" align="center" valign="top"> <a href="http://www.mcseworld.com/a/1931836884" target="_blank"> <img border="0" src="http://images.amazon.com/images/P/1931836884.01.MZZZZZZZ.jpg" width="111" height="140"></a></td> </tr> </if> <tr> <td class="alt1Active" width="100%" align="center" valign="top" colspan="5"><div class="smallfont"> <b>Please help support MCSE World by purchasing your books through these links to Amazon.com.</b></div> </td> </tr> </tbody> </table> </center> </div> <br> <!-- Book Content --> Code:
ALTER TABLE forum ADD bktitle VARCHAR ( 100 ) NOT NULL Code:
print_table_header ( "Forum Book Content Information" ) ; print_yes_no_row ( "Use Custom Book Info", 'forum[usedefbk]', $forum['usedefbk'] ) ; print_textarea_row ( "Book Content", 'forum[bkcontent]', $forum['bkcontent'] ) ; |
#5
|
|||
|
|||
Can anyone perhaps point me in the right direction to do this in vB 3.6? I've got the table modified, but I can't save changed in the AdminCP due ot the values not being defined in the class_dm.php file. As well, it looks like the conditionals are different now...at least that $foruminfo doesn't seem to be doing the trick anymore to get something on the showthread page.
Thanks. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|