Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 06-02-2008, 11:19 AM
Jonnyism Offline
forum loafer
 
Join Date: Jun 2008
Posts: 14
Where am I going wrong - attempted addon

PHP Code:
$addon_name "Jonnyisms Blog Addon";
$addon_description "Displays Jonnyisms Blog in a page.";
$addon_version "0.1";

$cutenews_current_blog $number "1"; include("cutenews/show_news.php");
$tpl str_replace("<CUTENEWSBLOG>",$cutenews_current_blog,$tpl); 

I have attempted to make an addon allowing me to put my cute news powered blog into a template page using the above code (I did this by editing the current date example), however, when I turn this on it puts my blog at the top of every page, and does not put it in place of the tag.

I am not too confident with php so really don't know what to look for, could anybody help me out with this one?
Reply With Quote
  #2  
Old 06-02-2008, 04:50 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
Try this and see how it works: (untested)
PHP Code:
$addon_name "Jonnyisms Blog Addon"
$addon_description "Displays Jonnyisms Blog in a page."
$addon_version "0.1"

function 
showNews(){
    
$number "1"
    include_once(
"cutenews/show_news.php"); 
}

$cutenews_current_blog showNews();
$tpl str_replace("<CUTENEWSBLOG>",$cutenews_current_blog,$tpl); 
__________________
Jay Williams | A Different View
Reply With Quote
  #3  
Old 06-02-2008, 04:51 PM
kevincrafts's Avatar
kevincrafts Offline
pixelpost guru
 
Join Date: Jul 2007
Location: Colorado
Posts: 434
Well, whatever the show_news.php does could change things. For instance, if in that file you had something that said "echo $string;" - that would be displayed at the top of the page.
__________________
Kevin | Light & Dark Photoblog

Reply With Quote
  #4  
Old 06-06-2008, 01:00 PM
TheMarco Offline
pixelpost guru
 
Join Date: Apr 2008
Posts: 195
Kevincrafts is right. You must make sure that whatever you call, NOTHING echo's out anything. Instead, showNews() should return something:

PHP Code:
function showNews(){

 ...
 ...
 ...

  return 
$stuff;
    



and then

PHP Code:
$cutenews_current_blog showNews();
$tpl str_replace("<CUTENEWSBLOG>",$cutenews_current_blog,$tpl); 
Functions not returning something but spitting out content in echo statements instead are most of the time bad practice anyway.
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 05:05 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs