PDA

View Full Version : Adding an external news to my main page


JohnBee
11-09-2004, 12:06 PM
I am mixing both vBadvance and an external news source to my front
page for various reasons but I cannot seem to get the outside source
to display the data in my adv_portal template.


Can anyone tell me how I sould go about getting this code to work?

<?PHP
include("path/to/show_news.php");
?>

tomshawk
11-09-2004, 11:25 PM
I am mixing both vBadvance and an external news source to my front
page for various reasons but I cannot seem to get the outside source
to display the data in my adv_portal template.


Can anyone tell me how I sould go about getting this code to work?

<?PHP
include("path/to/show_news.php");
?>

Could you post the contents of your template, and just for giggles, what is in this php file.

Normally to get a include statement like what you have there to work, it has to be added to your phpinclude template, then called out into a template, but a little more info on your part would help.

Here is an example of a template

adv_portal_whatever


<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">

<tr>
<td class="tcat">
<span class="smallfont">
<strong>$vba_options[portal_blockbullet] $mods[title]</strong>
</span>
</td>
</tr>

<tr><td class="$getbgrow" width="100%">$content</td></tr>
</table>
<br />


Then in the PHP file, you will call the template with a line like this
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_whatever') . '";');

But... Unless your file is using a third party program to pull Data, you need to use the phpinclude template. This is the part of the equation I dont know and am going to need to see what your pulling and how.

Good Luck

Our Sponsors
 

JohnBee
11-10-2004, 02:00 AM
Wow thanks I will try this ASAP.

the line:

<?PHP
include("path/to/show_news.php");
?>

Simply calls a template from a small php new script called cutenews.
its a very simple call, the news is very basic title and body plain text
content.

I want to get this in my homepage only for my headlines because
I don't like the limited image and text formating that vBadvance
gives me on my big news story.

If I can get this code to work on my vBadvance page I will be one
happy camper :D

Let me know if there is anything else you need to help me make
this work.

I will start on the changes in the monrning. thanks for you reply.

JohnBee
11-10-2004, 02:02 AM
Okay here is the show_news.php file

<?PHP

error_reporting (E_ALL ^ E_NOTICE);

$cutepath = __FILE__;
$cutepath = preg_replace( "'\\\show_news\.php'", "", $cutepath);
$cutepath = preg_replace( "'/show_news\.php'", "", $cutepath);

require_once("$cutepath/inc/functions.inc.php");
require_once("$cutepath/data/config.php");

//----------------------------------
// Check if we are included by PATH
//----------------------------------
if($HTTP_SERVER_VARS["HTTP_ACCEPT"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_CHARSET"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"] or $HTTP_SERVER_VARS["HTTP_CONNECTION"]){ /* do nothing */ }
elseif(eregi("show_news.php", $PHP_SELF)){
die("<h4>CuteNews has detected that you are including show_news.php using the URL to this file.<br>
This is incorrect and you must include it using the PATH to show_news.php</h4><br>Example:<br>
this is <font color=red>WRONG</font> :&nbsp;&nbsp; &lt;?PHP include(\"http://yoursite.com/cutenews/show_news.php\"); ?&gt;<br>
this is <font color=green>CORRECT</font>:&nbsp;&nbsp; &lt;?PHP include(\"cutenews/show_news.php\"); ?&gt;<br>
<br><BR>// <font size=2>if you think this message shouldn't be shown, open show_news.php and delete it from there</font>");
}
//----------------------------------
// End of the check
//----------------------------------

if(!isset($subaction) or $subaction == ""){ $subaction = $POST["subaction"]; }

if(!isset($template) or $template == "" or strtolower($template) == "default"){ require_once("$cutepath/data/Default.tpl"); }
else{
if(file_exists("$cutepath/data/${template}.tpl")){ require_once("$cutepath/data/${template}.tpl"); }
else{ die("Error!<br>the template <b>".htmlspecialchars($template)."</b> does not exists, note that templates are case sensetive and you must write the name exactly as it is"); }
}

// Prepare requested categories
if(eregi("[a-z]", $category)){
die("<b>Error</b>!<br>CuteNews has detected that you use \$category = \"$category\"; but you can call the categories only with their <b>ID</b> numbers and not with names<br>
example:<br><blockquote>&lt;?PHP<br>\$category = \"1\";<br>include(\"path/to/show_news.php\");<br>?&gt;</blockquote>");
}
$category = preg_replace("/ /", "", $category);
$tmp_cats_arr = explode(",", $category);
foreach($tmp_cats_arr as $key=>$value){
if($value != ""){ $requested_cats[$value] = TRUE; }
}

if($archive == ""){
$news_file = "$cutepath/data/news.txt";
$comm_file = "$cutepath/data/comments.txt";
}else{
$news_file = "$cutepath/data/archives/$archive.news.arch";
$comm_file = "$cutepath/data/archives/$archive.comments.arch";
}

$allow_add_comment = FALSE;
$allow_full_story = FALSE;
$allow_active_news = FALSE;
$allow_comments = FALSE;

//<<<------------ Detarime what user want to do
if( $CN_HALT != TRUE and $static != TRUE and ($subaction == "showcomments" or $subaction == "showfull" or $subaction == "addcomment") and ((!isset($category) or $category == "") or $requested_cats[$ucat] == TRUE) ){
if($subaction == "addcomment"){ $allow_add_comment = TRUE; $allow_comments = TRUE; }
if($subaction == "showcomments") $allow_comments = TRUE;
if(($subaction == "showcomments" or $allow_comments == TRUE) and $config_show_full_with_comments == "yes") $allow_full_story = TRUE;
if($subaction == "showfull") $allow_full_story = TRUE;
if($subaction == "showfull" and $config_show_comments_with_full == "yes") $allow_comments = TRUE;

}
else{
if($config_reverse_active == "yes"){ $reverse = TRUE; }
$allow_active_news = TRUE;
}
//----------->>> Detarime what user want to do

require("$cutepath/inc/shows.inc.php");
if($_GET['archive'] and $_GET['archive'] != ''){ $archive = $_GET['archive']; } // stupid fix ?
unset($static, $template, $requested_cats, $category, $catid, $cat,$reverse, $in_use, $archives_arr, $number, $no_prev, $no_next, $i, $showed, $prev, $used_archives);
?>
<!-- News Powered by CuteNews: http://cutephp.com/ -->

Hope this helps

Our Sponsors
 

tomshawk
11-10-2004, 03:27 AM
Hi JohnBee

I took a close look at Cutephp and I think the easiest way to do it is to scratch what I said before

open phpinclude and paste this at the bottom

ob_start();
require("path/to/show_news.php");
$news = ob_get_contents();
ob_end_clean();

Notice the path to the php file, just like like the one in your original post

Then create you adv_portal_whatever template and paste the below code into it.

$news
<br>

That should get it working.

Let us know if it does or not, k ;)

JohnBee
11-10-2004, 12:50 PM
is phpinclude a template?
or a file?

I searched for either I could not find them I did find phpinclude_start
and _end templates though.

JohnBee
11-10-2004, 01:03 PM
Okay I added that code to phpinclude_start (with correct path)
and then dropped the $news tag in my adv_portal template
"nothing" I tried putting the $news in various locations to test
if it wasnt interference but alas its the same on each occasion.

I double checked everything but it looks like all the info. is
correct.

is there anything else I can do to verify the info?

tomshawk
11-10-2004, 04:10 PM
Sorry, yes, phpinclude_start was the right one ;)

As for the other, you created a template, did you create the vbadvanced module and tell it to use that template, then add it to the default page, Yet?

Sory if you have, just checking

JohnBee
11-10-2004, 05:10 PM
YES! :D

Okay its working, well its a start but hey considering what I have been
through this is a huge improvement at least the content is making its
way into the vBadvance page now :o

There are a few things that I am unsure on how to handle.

It seemd like the news has lost all its formating, here is the tag
I used normally, perhaps you can see how it could be worked in
using your following technique.

<?PHP
$template = "BigNews";
$category = "1";
include("/home/servr/public_html/web/cutenews/show_news.php");
?>

Additionally I use this code to display my headlines

<?PHP
$number = "5";
$template = "Headlines";
$category = "2";
include("/home/servr/public_html/web/cutenews/show_news.php");
?>

BTW. this hack will come accross very well at the cutenews addons
& mod forums because alot of people use vBB there :)

This is very exciting I hope you make an official thread

tomshawk
11-11-2004, 02:50 AM
Hi JohnBee,

In the show_news.php file, try putting this code at the top of the file

<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><b>$vba_options[portal_blockbullet] News</b></span></td>
</tr>
<tr>
<td class="$getbgrow" width="100%">

And this code after it

</td>
</tr>
</table>
<br />
and see what it looks like, That should help a little, at least I hope.

In the first snippet of code, where it says News, Change that to something else, like you said before "BigNews"

Using the same steps in my previous posts, you can make many blocks that pull data from multiple sites or sources.

BTW, whats your site, so we can see the end result.

Good Luck and I'm glad I was able to help ;)

JohnBee
11-11-2004, 12:24 PM
Great

So im not totally clear on the idea so could you break it down
for me a little?

say I use this exact code in my regular web page.

<?PHP
$template = "BigNews";
$category = "1";
include("/home/servr/public_html/web/cutenews/show_news.php");
?>

Now how would I put this down into my vBadvance template?
I tried just dropping the extras like this:

ob_start();
require($template = "BigNews"; $category = "1"; "path/to/show_news.php");
$news = ob_get_contents();
ob_end_clean();

But obviously thats no good.
I also tried to use the following on my vBadvance custom page

$template = "BigNews";
$category = "1";
$news

That is not the way either, so how would I make the following call?

<?PHP
$number = "5";
$template = "Headlines";
$category = "2";
include("/home/servr/public_html/web/cutenews/show_news.php");
?>