vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Create Horizontal Widget? (https://vborg.vbsupport.ru/showthread.php?t=276855)

Budget101 01-12-2012 04:20 PM

Create Horizontal Widget?
 
When creating a new widget "Recent Articles" - the items appear vertically in a list. How would you change the layout so that the articles appear Horizontally (or side by side)

like this:

https://vborg.vbsupport.ru/external/2012/02/39.jpg

I want to be able to create a "Read More" article widget for additional similar articles

but right now, they display vertically rather than horizontally. The current code I am using to create the widget is:

Code:

// Set Your Section ID Here
$section = '2,3,4,5';
// Set The Number of Articles To Display
$limit = '5';
// Set The Height of The Thumbnail Image
$height = '100';
// Set The Width of The Thumbnail Image
$width = '100';

$articlegrab = vB::$db->query_read("
SELECT ".TABLE_PREFIX."cms_nodeinfo.nodeid
, ".TABLE_PREFIX."cms_nodeinfo.title
, ".TABLE_PREFIX."cms_article.previewimage
, ".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.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 ($section))
AND (".TABLE_PREFIX."cms_node.setpublish != 0)
ORDER BY ".TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit
");
$output.="<table>";
while($articleinfo = vB::$db->fetch_array($articlegrab)) {

$title = $articleinfo['title'];
$image = $articleinfo['previewimage'];
$nodeid = $articleinfo['nodeid'];
$url = $articleinfo['url'];
$fulltext = strip_bbcode($fulltext);
$text = preg_replace('/\[ATTACH\=CONFIG\]\d\d\[\/ATTACH\]/', '', $text);
$text = strip_bbcode($text);


if($text == '') $text = substr($fulltext, 0,150);

if($image != '') $output .= "<tr><td><img src='".$image."' width='".$width."px' align='left' height='75' HSPACE='5' VSPACE='3'/></td>";

$output .= "<td><b><a href='content.php?".$nodeid."-".$url."' align='top'>".$title."</a><p>".$text." </b></p><br/></td></tr>";
}
$output.="</table>";

TIA!

Lynne 01-12-2012 05:20 PM

You would need to create a grid that has a spot for this widget. Then create a layout from that grid and apply it to the section and make sure to put your widget in that specific spot in the layout.

Budget101 01-12-2012 06:50 PM

Hi Lynne, thank you for responding! I have a grid that has a spot for the widget. I have a layout from the grid.
The problem that I'm having is that this particular widget code returns the items vertically, rather than horizontally.
I need help editing the code (shown in the first post) to change how it appears so that instead of the items coming up vertically like this:

photo- link

photo- link

photo- link

they appear horizontally like this instead:

Photo Photo Photo
Link Link Link


The issue appears to be the table output- it repeats vertically-

if($text == '') $text = substr($fulltext, 0,150);

if($image != '') $output .= "<tr><td><img src='".$image."' width='".$width."px' align='left' height='75' HSPACE='5' VSPACE='3'/></td>";

$output .= "<td><b><a href='content.php?".$nodeid."-".$url."' align='top'>".$title."</a><p>".$text." </b></p><br/></td></tr>";
}
$output.="</table>";

But I'm not familiar with how to make it repeat horizontally instead. . .

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

I tried changing the table <td><tr> placements, but it just gave me errors. I would assume that I would have to create a class-style for it to follow to get it to repeat horizontally, rather than vertically, but I don't know where to begin to do that.

Lynne 01-13-2012 12:36 AM

Ah, I see what you mean. Can we get a link to see this?

Budget101 01-13-2012 03:01 PM

Quote:

Originally Posted by Lynne (Post 2287094)
Ah, I see what you mean. Can we get a link to see this?


Yes, you can view it here: link truncated

scroll to the bottom - this widget is located underneath the Comments Box.

(Thank you !)

Lynne 01-13-2012 05:02 PM

Have you tried using <tr width="33%"> ?

Budget101 01-16-2012 04:51 PM

Quote:

Originally Posted by Lynne (Post 2287350)
Have you tried using <tr width="33%"> ?

Hi lynne, thank you for the suggestion. I did give it a try, but the articles wouldn't populate at all when I added the width to it. It actually gave me a parse error:

Parse error: syntax error, unexpected T_LNUMBER in

I tried it several different ways in the <tr> and also in the table width itself.

kh99 01-16-2012 04:55 PM

If you're trying to insert width="33%" in a string that's delimited with double quotes, you have to escape the quotes, like:

Code:

$output .= "<tr width=\"33%\"> some stuff...";

Budget101 01-16-2012 05:13 PM

Thank you kh! I got it to narrow the table , now I just need it to repeat horizontally, rather than vertically... is there a way to incorporate repeat-x into output?

Code:

if($text == '') $text = substr($fulltext, 0,150);

if($image != '') $output .= "<tr><td><img src='".$image."' width='".$width."px' align='left' height='75' HSPACE='5' VSPACE='3'/></td>";

$output .= "<td><b><a href='/forum/content.php?".$nodeid."-".$url."' align='top'>".$title."</a><p>".$text." </b></p></br><p>".$description."</p><br/></td></tr>";
}
$output.="</table>";

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

I tried adding a div class and specifying it, but I can't seem to get the syntax right

Code:

<style>
#hloop
.hloop{
  border:1px solid green;
  padding:20px;
  vertical-align:top;
  width:200px;
  height:100px;
}
.hloop img{
  margin-left:10%;
}
</style>

Code:

$output.="<div class='hloop'>";
while($articleinfo = vB::$db->fetch_array($articlegrab)) {

$title = $articleinfo['title'];
$image = $articleinfo['previewimage'];
$description = $articleinfo['description'];
$nodeid = $articleinfo['nodeid'];
$url = $articleinfo['url'];
$fulltext = strip_bbcode($fulltext);
$text = preg_replace('/\[ATTACH\=CONFIG\]\d\d\[\/ATTACH\]/', '', $text);
$text = strip_bbcode($text);


if($text == '') $text = substr($fulltext, 0,150);

if($image != '') $output .= "<img src='".$image."' width='".$width."px' align='left' height='75' HSPACE='5' VSPACE='3'/>";

$output .= "<b><a href='/forum/content.php?".$nodeid."-".$url."' align='top'>".$title."</a><p>".$text." </b></p></br><p>".$description."</p><br/>";
}
$output.="</div>";



All times are GMT. The time now is 11:24 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.01150 seconds
  • Memory Usage 1,744KB
  • 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
  • (5)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete