vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Help with side blocks pease (https://vborg.vbsupport.ru/showthread.php?t=324031)

Phil Dart 12-16-2016 08:29 PM

Help with side blocks pease
 
Hello everyone - I wonder if someone could give some pointers please. I recently bought a forum that was already established, so I am pretty naive about the nuts and bolts behind the scene

The version is 4.2.3

There is currently a section that renders a selection of 4 random photos drawn from a gallery elsewhere. I would like to move it to a side block so I can use that space for something else. I stupidly thought I could copy and paste the template code into a side block and that would be that, having removed the title bar, but all that happens is that the side block renders some of the code, irrespective of whether I paste it as html or php

The template code that currently does the job is below.

<vb:if condition="!empty($pppro_imagebits)">
<div id="pppro"></div>
<ol class="floatcontainer">
<li class="forumbit_nopost">
<div class="forumhead foruminfo L1 collapse">
<a class="collapse" id="collapse_featurepal" href="forum.php#top"><img src="images/buttons/collapse_40b.png" alt="" /></a>
<h2><span class="forumtitle">&nbsp;&nbsp;&nbsp;From the Gallery</span></h2>
</div>
<ol class="childforum">
<li class="forumbit_post">
<div id="featurepal" class="forumrow table">
<table class="tborder" cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
<td>
<br />
<table cellpadding="$stylevar[cellpadding]" cellspacing="1" border="0" width="100%">
<tr>
{vb:raw pppro_imagebits}
</tr>
</table>
<br />
</td>
</tr>
</table>
</div>
</li>
</ol>
</li>
</ol>
<br />
</vb:if>

Anyone kind enough to reply should assume I am an idiot with no knowledge. I am more than happy to be talked down to

Best wishes

Lynne 12-17-2016 01:11 AM

What hook are you using to add the needed php code and what is the code you are adding there?

Phil Dart 12-17-2016 08:01 AM

Thanks for your reply Lynne

I know nothing about hooks I'm afraid:confused: I simply pasted the code above into the block, then tried experimenting with it when I found it didn't work.

MarkFL 12-17-2016 08:36 AM

Typically in a forum block, you need to return data, just as if you are operating inside a PHP function with local variables. You would need to build your data, then render your HTML containing the data you built, and return the finished HTML.

For example, here is the PHP code I use for a simple forum block that displays the users who have visited the site within the last 7 days:

PHP Code:

global $vbulletin$db;
$output '<div class="restore"><ul>';

$users_visited $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE lastvisit >= " 
TIMENOW " - " 86400 "
    AND usergroupid != 8
    ORDER BY lastvisit DESC
"
);

$vcount 0;
while (
$visitor $db->fetch_array($users_visited))
{
    
$output .= '<li>' visitor_link($visitor$visitor['lastvisit']) . '</li>';
    
$vcount++;
}

$output .= '</ul></div>';

$output '<div style="text-align: center; font-weight: bold; margin-bottom: 1em">' $vcount ' Visiting Members</div>' $output;

return 
$output;

function 
visitor_link($user_name$dateline)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user_name['username'];

    if (
$user_name['displaygroupid'])
    {
        
$groupid $user_name['displaygroupid'];
    }
    else
    {
        
$groupid $user_name['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Last Visited: ' vbdate($vbulletin->options['dateformat'], $dateline1) . ' at ' vbdate($vbulletin->options['timeformat'], $dateline);
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user_name['username'] . $close_tag '</a>';



scottkoz20 12-17-2016 04:48 PM

Simple is a relative term Mark :)


However, I have found that using a table with a sidebar block does not output with the desired effect. My knowledge of writing PHP is limited as well. I would take some time and research past threads, someone might have already built out something that you are looking for (you might need to modify a bit)

CAG CheechDogg 12-17-2016 10:45 PM

I have a forum side block that will pull a single image from any gallery you want ....

Replace the id which is highlighted in red with the id of the album which you want to use ...
You can also change the width of the sideblock as well, the width for this one is highlighted in red and its 225 px ...



Code:

// -- Widget Configuration --
$use_vB_thumbnail_size    = false;
$use_custom_css        = true;
$twidth                = 225;
$limit                    = 1;
$albums_list            = "17";


// -- Nothing to configure below this line --
if ($use_custom_css){
    $pthumb    = 'class="pthumb"';
    $pcaption    = 'class="pcaption"';
    $pmore        = 'class="pmore"';
    $pstyle        = '';
}else{
    $pthumb    = 'style="text-align:center;"';
    $pcaption    = 'style="text-align:center;font-style:italic;font-family: Times, serif;margin-bottom:10px;"';
    $pmore        = 'style="text-align:right;display:block;"';
    $pstyle        = 'style="border: 1px solid black;padding:4px;background: white;"';
}
if ($albums_list!="") $sup_cond = "AND alb.albumid IN ($albums_list)"; else $sup_cond ="";
ob_start();
require_once(DIR . '/includes/functions_album.php');
require_once(DIR . '/includes/functions_user.php');
$pic_get = vB::$db->query_read("
    SELECT    alb.albumid, att.attachmentid, att.userid, att.caption, att.dateline, att.state, fdt.filesize, IF(fdt.thumbnail_filesize > 0, 1, 0) AS hasthumbnail, fdt.thumbnail_dateline, fdt.thumbnail_width, fdt.thumbnail_height, u.username
    FROM ".TABLE_PREFIX."album AS alb
    LEFT JOIN ".TABLE_PREFIX."attachment AS att ON alb.albumid = att.contentid
    LEFT JOIN ".TABLE_PREFIX."filedata AS fdt ON att.filedataid = fdt.filedataid
    LEFT JOIN ".TABLE_PREFIX."user AS u ON att.userid = u.userid
    WHERE alb.state = 'public' AND att.contenttypeid = '8' $sup_cond
    ORDER BY rand(" . microtime()*1000000 . ")
  LIMIT $limit");
  $output_bits = "";
  while($pic = vB::$db->fetch_array($pic_get))
  {
    $albuminfo = fetch_albuminfo($pic[albumid]);
    $picture = prepare_pictureinfo_thumb($pic, $albuminfo);
    if ($use_vB_thumbnail_size) $size = $picture[dimensions]; else $size = "width=$twidth";
    $output_bits .= "<div $pthumb><a href=\"album.php?{$vbulletin->session->vars['sessionurl']}albumid={$pic[albumid]}&attachmentid={$picture[attachmentid]}\"><img $pstyle src=\"attachment.php?{$vbulletin->session->vars['sessionurl']}attachmentid={$picture[attachmentid]}&thumb=0&d={$picture[thumbnail_dateline]}\" alt=\"{$picture[caption_preview]}\" $size /></a>";
    $output_bits .= "</div><div $pcaption>{$picture[caption_preview]} by {$pic[username]}</div>";
  }
$output_bits .= '<span '.$pmore.'><a href="album.php" alt="To the albums">More...</a></span>';
$output = $output_bits;
ob_end_clean();
return $output;


Phil Dart 12-18-2016 06:44 AM

Thanks for your replies guys.
The current setup renders four random thumbs drawn from multiple albums in Photopost Pro, so although I see where you're coming from CAG, it doesn't really work because there are many album lists not just one.

The code below works perfectly in the main body of the home page, and all I'm trying to do is make it work in a sideblock instead.

Mark, the data is built and works just fine where it is, I just have no understanding of hooks and returns and so on to make it work in a block. I know I am probably being particularly dim, but when you don't know, you just don't know.
Code:

<vb:if condition="!empty($pppro_imagebits)">
<div id="pppro"></div>
<ol class="floatcontainer">
    <li class="forumbit_nopost">

// -- i know I can get rid of this <div> for the haeder, it won't be needed, and the ol and li classes too --
<div class="forumhead foruminfo L1 collapse">
        <a class="collapse" id="collapse_featurepal" href="forum.php#top"><img src="images/buttons/collapse_40b.png" alt="" /></a>
    <h2>
        <span class="forumtitle">{vb:rawphrase pp_featured_photos}</span></h2>
</div>


<ol class="childforum">
    <li class="forumbit_post">
<div id="featurepal" class="forumrow table">
<table class="tborder" cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
<td>
<br />
    <table cellpadding="$stylevar[cellpadding]" cellspacing="1" border="0" width="100%">
      <tr>
          {vb:raw pppro_imagebits}
      </tr>
    </table>
<br />
</td>
</tr>

</table>
    </div>
</li>
    </ol>
</li>
    </ol>
<br />
</vb:if>


CAG CheechDogg 12-18-2016 11:14 PM

Ok try this ...

Make a new template and call it some like "block_html_random_photos"

Inside the template add this


Code:

<vb:if condition="is_member_of($bbuserinfo, 9)">
<li>
        <div class="block smaller" id="pppro">




                <div class="blocksubhead">
                        <a class="collapse" id="collapse_block_html_{vb:raw blockinfo.blockid}" href="{vb:raw relpath}#top"><img alt="" src="{vb:stylevar imgdir_button}/collapse_40b.png" width="16" height="16" id="collapseimg_html_{vb:raw blockinfo.blockid}"/></a>


                        <span class="blocktitle">{vb:rawphrase pp_featured_photos}</span>
                </div>
                <div class="widget_content blockbody floatcontainer">
                <div id="block_html_{vb:raw blockinfo.blockid}" class="blockrow">










                        {vb:raw pppro_imagebits}
                </div>
                </div>
        </div>
        <div class="underblock"></div>








</li>


</vb:if>

Then make a new forum sideblock and call it "Random Photos"

Make it an html block then inside the content block add this

Code:

<div align="center"><!--{vb:raw pppro_imagebits}--></div>
or

Code:

<div align="center">{vb:raw pppro_imagebits}</div>
In the template to use add this "block_html_random_photos"

One of these should work ....

Let me know if it works for yah'

Phil Dart 12-19-2016 09:06 AM

Thanks for your reply. Unfortuantely neither works. They both render nothing at all, but I'm really grateful to you for trying.

Lynne 12-19-2016 04:08 PM

Are you putting this side block on the same page that the current random images are on? If you go to admincp > Products & Hooks > Manage Products, do you see anything titled that may be the modification being used here? If so, then go to admincp > Products & Hooks > Hook Manager and look up the plugins for that Product - can you give us the titles and then hook location for them? And, are you creating a Forum Block or are you trying to create a CMS Block?


All times are GMT. The time now is 08:09 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.01487 seconds
  • Memory Usage 1,791KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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