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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2013, 02:02 PM
tounet's Avatar
tounet tounet is offline
 
Join Date: May 2007
Location: Algeria
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help : customise block in the sidebare

I have a php file inspire the product "Rate My Photo (HorOrNot Clone)" and correctly displays the best picture of my database and uses a template but I am unable to make my block:

the php code

PHP Code:
<?php 

global $vbulletin;
// Include Globals
    
require_once('./global.php');

$bestphoto =$vbulletin->db->query_first("SELECT * FROM vb_ratemyphoto_photos WHERE approved=1 AND hidden=0 

AND rating>0 ORDER BY rating DESC, votes DESC LIMIT 1"
);
    
$besttitle htmlspecialchars_uni($bestphoto["title"]);
    
$bestphotoname $bestphoto["logo"];
    
$bestvotes $bestphoto["votes"];
    
$bestrating $bestphoto["rating"];
        
$templater vB_Template::create('block-photo');
        
$templater->register('besttitle'$besttitle);
    
$templater->register('bestphotoname'$bestphotoname);
        
$templater->register('bestvotes'$bestvotes);
    
$templater->register('bestrating'$bestrating);
    
$templater->register('bestuserid'$bestphoto[userid]);
    
$templater->register('bestusername'$bestphoto[username]);    
    
$templater->register('catid'$catid);
        
print_output($templater->render());
 
      
?>
the template :

HTML Code:
<li>
	<div class="block smaller">
		<div class="blocksubhead">
		Meilleur photo	
		</div>
		<div id="block_title" class="blockbody floatcontainer" {vb:raw content.style}>
			<div class="blockrow">

	<img src="../forum/ratemyphoto/photo/thumbs/{vb:raw bestphotoname}"/>

			</div>
		</div>
	</div>
	<div class="underblock"></div>
</li>
		</div>
	</div>
</div>	
<div class="underblock"></div>
Reply With Quote
  #2  
Old 01-02-2013, 02:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this for the code:

Code:
global $vbulletin;

$bestphoto =$vbulletin->db->query_first("SELECT * FROM vb_ratemyphoto_photos WHERE approved=1 AND hidden=0 

AND rating>0 ORDER BY rating DESC, votes DESC LIMIT 1");
    $besttitle = htmlspecialchars_uni($bestphoto["title"]);
    $bestphotoname = $bestphoto["logo"];
    $bestvotes = $bestphoto["votes"];
    $bestrating = $bestphoto["rating"];
        $templater = vB_Template::create('block-photo');
        $templater->register('besttitle', $besttitle);
    $templater->register('bestphotoname', $bestphotoname);
        $templater->register('bestvotes', $bestvotes);
    $templater->register('bestrating', $bestrating);
    $templater->register('bestuserid', $bestphoto[userid]);
    $templater->register('bestusername', $bestphoto[username]);    
    $templater->register('catid', $catid);
    return $templater->render();
Reply With Quote
  #3  
Old 01-02-2013, 02:29 PM
tounet's Avatar
tounet tounet is offline
 
Join Date: May 2007
Location: Algeria
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you but the block still appears empty
Reply With Quote
  #4  
Old 01-02-2013, 03:52 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you created the template called "block-photo" (or does it exist already)?
Reply With Quote
  #5  
Old 01-02-2013, 04:12 PM
tounet's Avatar
tounet tounet is offline
 
Join Date: May 2007
Location: Algeria
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Have you created the template called "block-photo" (or does it exist already)?
I created it myself

her the link demo : her
Reply With Quote
  #6  
Old 01-02-2013, 04:28 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I can't really tell what's going on from that. One thing is that the template you posted doesn't have the tags matched - there's one more </div> than there is <div>.

Are you entering that template name in "Template to use"? If so, set "Template to Use" to block_html. Also, set "Cache Time (in minutes)" to 0 until you get it working, then set it to the number of minutes you want to cache.
Reply With Quote
  #7  
Old 01-02-2013, 04:40 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Replace this line:
PHP Code:
    return $templater->render(); 
With these:
PHP Code:
    $my_output $templater->render();
    return 
$my_output
And Kevin is correct in that your html template is improper html. I have no idea what it will do to the page if you leave it like that.
Reply With Quote
  #8  
Old 01-02-2013, 04:52 PM
tounet's Avatar
tounet tounet is offline
 
Join Date: May 2007
Location: Algeria
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the new template :

HTML Code:
<div class="block smaller">
	<div class="blocksubhead">
		Meilleur photo
	</div>
	<div class="widget_content blockbody floatcontainer">
		<div class="blockrow" align="center">
			<A HREF="ratemyphoto/photos/{vb:raw bestphotoname}"><img border="0" src="ratemyphoto/photos/thumbs/{vb:raw bestphotoname}"></A><br />
			
		</div>
	</div>
</div>	
<div class="underblock"></div>
I have set "Template to Use" to block_html. and, set "Cache Time (in minutes)" to 0



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

Quote:
Originally Posted by Lynne View Post
Replace this line:
PHP Code:
    return $templater->render(); 
With these:
PHP Code:
    $my_output $templater->render();
    return 
$my_output
And Kevin is correct in that your html template is improper html. I have no idea what it will do to the page if you leave it like that.
PHP Code:
$my_output $templater->render();
    return 
$my_output
I tested with and it does not work
Reply With Quote
  #9  
Old 01-02-2013, 05:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tounet View Post
I have set "Template to Use" to block_html.
It says "block_photo" (unless you meant you changed it after making the screen grab). It *is* possible to use a custom template name there, but unless you want the "frame" part to look different than other blocks, I wouldn't do it that way.
Reply With Quote
  #10  
Old 01-02-2013, 05:03 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All your variables need to be returned as an array. Example:
PHP Code:
    $my_output = array('besttitle'$besttitle
    
'bestphotoname'$bestphotoname);
return 
$my_output 
And then you may use those variables in your template. I have a Users Online Block that I released (see my profile) and you can see how to use a custom template and return custom variables.
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 10:18 PM.


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.06517 seconds
  • Memory Usage 2,302KB
  • Queries Executed 12 (?)
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
  • (1)bbcode_code
  • (2)bbcode_html
  • (7)bbcode_php
  • (3)bbcode_quote
  • (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_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