Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2016, 08:29 PM
Phil Dart Phil Dart is offline
 
Join Date: Dec 2016
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 12-17-2016, 01:11 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What hook are you using to add the needed php code and what is the code you are adding there?
Reply With Quote
  #3  
Old 12-17-2016, 08:01 AM
Phil Dart Phil Dart is offline
 
Join Date: Dec 2016
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply Lynne

I know nothing about hooks I'm afraid I simply pasted the code above into the block, then tried experimenting with it when I found it didn't work.
Reply With Quote
  #4  
Old 12-17-2016, 08:36 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>';

Reply With Quote
  #5  
Old 12-17-2016, 04:48 PM
scottkoz20 scottkoz20 is offline
 
Join Date: Dec 2015
Location: Lewiston, NY
Posts: 344
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #6  
Old 12-17-2016, 10:45 PM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
Reply With Quote
  #7  
Old 12-18-2016, 06:44 AM
Phil Dart Phil Dart is offline
 
Join Date: Dec 2016
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #8  
Old 12-18-2016, 11:14 PM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'
Reply With Quote
  #9  
Old 12-19-2016, 09:06 AM
Phil Dart Phil Dart is offline
 
Join Date: Dec 2016
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply. Unfortuantely neither works. They both render nothing at all, but I'm really grateful to you for trying.
Reply With Quote
  #10  
Old 12-19-2016, 04:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:25 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04464 seconds
  • Memory Usage 2,310KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete