vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   WebTemplates 3.5.x: VB Integrated CMS (Content Management System) (https://vborg.vbsupport.ru/showthread.php?t=103076)

Logician 09-14-2007 06:20 AM

Quote:

Originally Posted by toucan42 (Post 1338526)
I did a search for "count" and "iterate" on this mod and found nothing (can't handle going through 50 pages of posts) so I will ask my question:

I want to create a page that displays the results of a query in three columns. This means I need code within the query that iterates the records and keeps count - when it reaches three it will end a table row then start a new row.

how can i add code for a multiline recordset such that I can keep a counter as the records are returned?

I wouldn't think it is possible.

toucan42 09-14-2007 11:37 AM

Yeah that's what I am encountering though I may have a method that uses CSS instead of tables for the layout.

Thank you for this awesome hack - this is going to enable so many things for my site.

tunamix 09-16-2007 02:43 AM

Great job with this mod.
Thank you!

da prez 09-16-2007 08:49 PM

does anyone have some created web queries they wouldn't mind sharing ?

thanks

RollaJedi 09-17-2007 03:05 PM

i solved my problems and just want to say thank you to Logician for this great mod!

toucan42 09-20-2007 03:39 PM

I have a question - I am running a web query against a custom table for which many columns are NULL allowed. When I am looping the recordset in the WebQuery it seems that as soon as I encounter a NULL it stops processing that record.

Say my query is:

SELECT field1,field2,field3 FROM sometable WHERE condition = somecondition

in the WebQuery Query Result Row I am assigning the values of fields 1,2 and 3 to a string to be output to the screen:

var someString = '$WQfield[field1]' + ' some words ' + '$WQfield[field2]' + ' more words ' + '$WQfield[field3]'

If field2 is NULL - a valid data condition - field3 never shows up

Not sure if you have a tip on how to preserve NULL but also how to handle it within the WebQuery Query Result Row window?

toucan42 09-20-2007 03:57 PM

Quote:

Originally Posted by leitel (Post 900172)
I am trying to format the output so that ONLY IF there is a 'dept', it will print out.
I tried putting code in the query output area as well as at the main page template.

Code:

$WQfield[name]<br/>
<if condition="$WQfield['dept']">
    $WQfield[dept]<br/>
</if>


Thanks! :)



This question earlier may apply - how can you test the condition of the return set for a field?

kollam003 09-23-2007 03:52 AM

Installed and works like a charm , you have very well explained for even a newbie would do it professionally .

Kudos

Clicks Install

Wolfhawk 09-23-2007 07:32 AM

Awesome product ya created! Thanks a Million! Setup was extremely simple, Your "tutorial" and User Manual is very understandable and easy to follow...Man, the possibilities!

::: Running off to format some templates---Not forgetting to click the Install button and ratings on my way out :::

Great Job Logician! Keep up the good work!

TigerWare 10-07-2007 08:30 AM

Quote:

Originally Posted by da prez (Post 1340386)
does anyone have some created web queries they wouldn't mind sharing ?

thanks

Maybe there should be a repository somewhere?

Here is one that I have implemented which appears at the bottom of an article page written in LWT. The idea is to provide readers with snippets of comments made about the page they have just read, plus a visible link to a specific thread in the forum to read fully or add comments of their own. It displays a collapsable table containing the last 3 comments to the specific thread specified in the query. Text from each post is truncated at 500 characters. If there are no replies to the specified threadid, then the table content reverts to a generic "Be the first to add a comment" style.

Quote:

Query name: $WQ_comments_sometitle
Advanced Query?: Yes
Description: Displays information about comments for this page.

Query: (Required ThreadID is hard-coded in the WHERE clause)
Code:

select thr.threadid AS threadid, pst.title AS title, thr.firstpostid AS firstpostid, thr.replycount AS replycount, thr.views AS views, pst.postid AS postid, usr.username AS username, pst.dateline AS dateline, pst.userid AS userid, LEFT(pst.pagetext, 500) AS pagetext FROM thread AS thr LEFT JOIN post AS pst ON(thr.threadid = pst.threadid) LEFT JOIN user AS usr ON(usr.userid = pst.userid) WHERE thr.threadid = 0000 AND pst.postid <> thr.firstpostid  ORDER BY pst.postid DESC LIMIT 3
Query PHPInclude Code (Before): (Required ThreadID is hard-coded in the WHERE clause)
PHP Code:

$queryfirstpostid $db->query_first("SELECT firstpostid FROM " TABLE_PREFIX "thread AS thread WHERE threadid = 0000");
$firstpostid $queryfirstpostid[firstpostid]; 

The above PHPInclude provides the WebQuery with a variable [$firstpostid], which contains the first post id of the required thread. This variable is consumed in the 'Query No Results Row' which forms part of the link to the thread reply editor screen. (Many thanks to Logican for input on this).

Result Prefix Code:
HTML Code:

<div style="padding-bottom:15px">
  <table align="center" border="0" cellpadding="6" cellspacing="1" class="tborder" width="75%">
    <thead>
      <tr><td class="tcat"><a href="#top" onclick="return toggle_collapse('mysite_comments_module')" style="float:right"><img alt="" border="0" id="collapseimg_mysite_comments_module" src="images/buttons/collapse_tcat.gif" /></a>
      <span class="smallfont"><strong>&raquo; Discussion &amp; Comments...</strong></span></td></tr>
    </thead>
    <tbody id="collapseobj_mysite_comments_module" style="">

Query Result Row:
HTML Code:

<tr><td><span class="smallfont">&nbsp;</span></td></tr>
      <tr>
        <td class="thead"><a href="showthread.php?t=$WQfield[threadid]" title="[click here to view other comments]" target="_blank">$WQfield[title]</a></td>
      </tr>
      <tr>
        <td class="alt2">
          <div class="smallfont"><strong>Posted By</strong>:&nbsp;<span style="cursor:pointer" onclick="window.open('member.php?u=$WQfield[userid]')">$WQfield[username]</span></div>
          <div class="smallfont"><strong>Posted On</strong>:&nbsp;$WQfield[dateline]</div>
          <br/>
          <table align="center" border="0" cellpadding="6" cellspacing="1" class="tborder" width="95%">
            <tr>
              <td class="alt1">
                $WQfield[pagetext]<span class="smallfont"><a href="showthread.php?p=$WQfield[postid]#post$WQfield[postid]" title="[click here to read more]" target="_blank">...</a></span>
              </td>
            </tr>
          </table>
          <br/>
        </td>
      </tr>
      <tr class="thead"><td><span class="smallfont">Views ($WQfield[views]) - Comments ($WQfield[replycount]) - <a href="showthread.php?t=$WQfield[threadid]" title="[click here to view other comments]" target="_blank">View</a> or <a href="newreply.php?do=newreply&noquote=1&p=$WQfield[firstpostid]" target="_blank" title="[click here to add your comment now]">Add</a> Comments</span></td></tr>

Result Affix Code:
HTML Code:

</tbody>
  </table>
</div>

Query No Result Row:
HTML Code:

<tr><td class="alt2"><span class="smallfont">Be the first to <a href="newreply.php?do=newreply&noquote=1&p=$firstpostid" target="_blank" title="[click here to add your comment now]">Add</a> a comment.</span></td></tr>
BB Code Parsed Field Names: pagetext (can be omitted if your template is 'text parsed')
Date Parsed Field Names: dateline

[Note: If your template is 'text parsed' please ensure that the HTML shown above contains NO line breaks. This would be interpreted and a hard break added to each line with a <br/> HTML code. This will make the formatting look very strange]
** edit - see below **
The only caveat in the above configuration is the hard-coded id in the Query No Result Row. This is required because the LWT does not parse field result values in anything other than the Query Result Row. If the LWT could parse field values in Result Prefix Code, Result Affix Code and Query No Result Row, it would be utterly fantastic!

@Logican, is my above enhancement suggestion something that you may be planning for a furture version?


** Update **
Text in grey (above) is no longer relevant due to Logican's input. The example has now been enhanced to incorporate suggested php pre-query. Thanks Logican!

Anyway, I hope this gives an idea of what can be done. I am really just starting to learn certain aspects of the LWT, and it helps in learning mySQL syntax too, which is a plus! LWT rocks! :up:


All times are GMT. The time now is 09:31 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.02037 seconds
  • Memory Usage 1,779KB
  • 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_code_printable
  • (4)bbcode_html_printable
  • (1)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)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