vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   WebTemplates 3.x: VB Integrated Content Management System (https://vborg.vbsupport.ru/showthread.php?t=76422)

Marco van Herwaarden 04-17-2005 05:18 PM

Nested selects also will not do this trick i think.

Robert Basil 04-17-2005 07:59 PM

Even if I could get the query to display the latest single post in each forum and then sort by forum name I would be happy.

Right now I can get it to display a single post from each forum and sort by forum, but it's displaying the oldest post in the forum and not the latest.

SELECT t.threadid, t.title, t.firstpostid, t.lastpost, f.title as forumtitle, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, p.pagetext, t.iconid, t.forumid
FROM thread t
LEFT JOIN post p ON p.postid = t.firstpostid
LEFT JOIN forum f ON f.forumid = t.forumid
WHERE t.forumid
IN ( 19, 116 )
AND t.open = '1'
AND t.visible = '1'
GROUP BY f.title
ORDER BY forumtitle DESC
LIMIT 0 , 3

Marco van Herwaarden 04-17-2005 08:09 PM

Maybe add a ORDDR BY t.dateline DESC to it

Robert Basil 04-18-2005 04:09 AM

Quote:

Originally Posted by MarcoH64
Maybe add a ORDDR BY t.dateline DESC to it

Tried that but the query does not like 2 ORDER BY lines.

I also tried removing the ORDER BY line and adding:


ORDER BY t.dateline ASC

or

ORDER BY t.dateline DESC

Both lines in the query still bring up the oldest (first) thread in the forum and not the latest thread. :disappointed:

Marco van Herwaarden 04-18-2005 07:29 AM

Change
PHP Code:

ORDER BY forumtitle DESC 

To:
PHP Code:

ORDER BY t.dateline DESCforumtitle DESC 


Robert Basil 04-18-2005 07:56 AM

When I use:

Quote:

SELECT t.threadid, t.title, t.firstpostid, t.lastpost, f.title as forumtitle, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, p.pagetext, t.iconid, t.forumid
FROM thread t
LEFT JOIN post p ON p.postid = t.firstpostid
LEFT JOIN forum f ON f.forumid = t.forumid
WHERE t.forumid
IN (82,89,83,134,135,136,13,14,23,16,17,18,20,21,22,2 4,130,129,125,116,19)
AND t.open = '1'
AND t.visible = '1'
GROUP BY f.title
ORDER BY t.dateline DESC, forumtitle DESC
LIMIT 0 , 100
The forums are not in order and the posts are not the last posts.

When I use:

Quote:

SELECT t.threadid, t.title, t.firstpostid, t.lastpost, f.title as forumtitle, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, p.pagetext, t.iconid, t.forumid
FROM thread t
LEFT JOIN post p ON p.postid = t.firstpostid
LEFT JOIN forum f ON f.forumid = t.forumid
WHERE t.forumid
IN (82,89,83,134,135,136,13,14,23,16,17,18,20,21,22,2 4,130,129,125,116,19)
AND t.open = '1'
AND t.visible = '1'
GROUP BY f.title
ORDER BY t.dateline ASC, forumtitle DESC
LIMIT 0 , 100
The forums are in order but it's still showing the first posts (not the latest ones).

Logician 04-18-2005 10:27 AM

@Sportbikeworld : I don't think it is possible to grab the data you want with one query. I'd suggest to give up and use multiple webqueries to compile this data. I think you don't want to increase the query count of your webtemplate with a single query for each forum but this shouldn't cause a big performance problem so try it.

@Spinball : Webtemplate PHP parsing is exactly same as vbulletin's PHP parsing in phpinclude template and you are not able to use the other webtemplate features in a PHP parsed webtemplate like automatic header/footer inclusion. However you should consider:
a) If your PHP code is basic : Make your webtemplate parsing TXT or HTML (instead of PHP) and run your PHP code inside PHP parsed template of webtemplate.
b) If your PHP code is advanced : Grab vb header and footer inside your PHP code with PHP commands as well like:

eval('$headinclude = "' . fetch_template('headinclude') . '";');
eval('$header = "' . fetch_template('header') . '";');
eval('$footer = "' . fetch_template('footer') . '";');

Robert Basil 04-18-2005 10:45 AM

Quote:

Originally Posted by Logician
@Sportbikeworld : I don't think it is possible to grab the data you want with one query. I'd suggest to give up and use multiple webqueries to compile this data. I think you don't want to increase the query count of your webtemplate with a single query for each forum but this shouldn't cause a big performance problem so try it.

Darn, I have over 150 forums and need to query just about all of them. I was hoping to not have to re-enter a webquery for each one.

I wish you had a way to copy a default query over and over in the admin area.

Thanks for the help though. Still very happy with the hack. :)

Spinball 04-18-2005 04:05 PM

Quote:

Originally Posted by Logician
@Spinball : Webtemplate PHP parsing is exactly same as vbulletin's PHP parsing in phpinclude template and you are not able to use the other webtemplate features in a PHP parsed webtemplate like automatic header/footer inclusion. However you should consider:
a) If your PHP code is basic : Make your webtemplate parsing TXT or HTML (instead of PHP) and run your PHP code inside PHP parsed template of webtemplate.
b) If your PHP code is advanced : Grab vb header and footer inside your PHP code with PHP commands as well like:

eval('$headinclude = "' . fetch_template('headinclude') . '";');
eval('$header = "' . fetch_template('header') . '";');
eval('$footer = "' . fetch_template('footer') . '";');

Thanks, Logician.
I did as you suggested and got a header and footer. No navbar, page title or page in a category table, though.
What I want to do is run a fairly complex PHP script which allows people to search for a make & model of DVD player, read the hacks for it, comment and provide feedback on those hacks and submit and edit new ones.
All while maintaining the logged-in appearance of the forums. I want to write the user id to any comments/hacks records they contribute and display their user name from the vB database in the displayed records.
Now writing that script is well within my capabilities. Having it all happen within the forum 'environment' is not.
Help!
Thanks.

cessna140 04-21-2005 05:35 PM

Hey Logician!

Got the following error when trying to update the database. Ran it both ways. Know what this means?

==============
Error

SQL-query :

--

MySQL said:
#1064 - You have an error in your SQL syntax near '--' at line 1
===============

Clark


All times are GMT. The time now is 09:58 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.01247 seconds
  • Memory Usage 1,753KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete