1 (edited by 2012-10-19 10:57:27)

Topic: N00b questions: showing Full Story & Comments on the same page, etc.

Dear CuteNews gurus!

I'm starting my own site now, and I'd like to use CuteNews for it.
I installed the latest version, and it works, but there are some issues. Unfortunately my knowledge of PHP leads to zero so I'm sorry if I can't figure out the basic points.

I have a structure like this: index.php page contains a script where other pages are included:
<?php
$PARAM=array('p' => 'home');
$PARAM=array_merge($PARAM,$_GET);
switch($PARAM['p'])
{
case 'home': include 'home/_home.php'; break;
case 'news': include 'news/_news.php'; break;
- links to other pages here -
}

The links look like:
NEWS

So, the page "news.php" has some info and the following code:
<?PHP
$template = "irry";
include("cutenews/show_news.php");
?>

The issue occurs with links "Read more" (full story) and Comments: they just point to index.php (the index page of my site), and no Full Story or Comments are actually shown.

I modified script like this:
<?PHP
$PHP_SELF = "?p=news";
$template = "irry";
include("cutenews/show_news.php");
?>

It shows me the error message about non-existing page.

$PHP_SELF = "news.php"; also doesn't work, just the error message differs.

Could somebody tell me how to make my scripts work with this structure, please? Thank you very much!
I would like to avoid rewriting the whole site structure as shown in examples provided with the installation, 'cause there are reasons for this.

2 (edited by 2012-10-20 08:42:58)

Re: N00b questions: showing Full Story & Comments on the same page, etc.

Instead of

<?PHP
$PHP_SELF = "?p=news";
$template = "irry";
include("cutenews/show_news.php");

try using

<?PHP
$user_query = "p=news";
$template = "irry";
include("cutenews/show_news.php");

I'm not up to date with CuteNews 1.5 but I know that worked until CuteNews 1.4.7, so it's worth giving a shot. http://cutephp.com/forum/style_emoticons/default/smile.gif

3 (edited by 2012-10-22 07:56:35)

Re: N00b questions: showing Full Story & Comments on the same page, etc.

(lKj), thank you very much for the answer!
Unfortunately, it didn't work: the link points to the Index page, dunno why((( It shouldn't be like that, by logic.
I tried

$user_query = "p=news";


and

$user_query = "?p=news";


too
but the result is the same.
Should I downgrade to v.1.4.7, what do you think?

4 (edited by 2012-10-22 13:14:30)

Re: N00b questions: showing Full Story & Comments on the same page, etc.

I'm sorry, I should have checked CuteNews 1.5.0 before assuming it had the same behavior as 1.4.7.
Personally, I think CuteNews 1.5 is pretty wicked and it has a nicer design and some better browser compatibility than 1.4.7, so downgrading isn't an ideal solution.

We can just change our strategy: the links CuteNews generates always contain ?subaction in them, e.g. ?subaction=showcomments or ?subaction=showfull. Provided that you don't use that parameter anywhere else on your site, we can just include your news page when there's ?subaction in the link.

The code you posted:

$PARAM=array('p' => 'home');
$PARAM=array_merge($PARAM,$_GET);
switch($PARAM['p'])
{
case 'home': include 'home/_home.php'; break;
case 'news': include 'news/_news.php'; break;
- links to other pages here -
}

My proposition:

$page = 'home'; // Default

if(isset($_GET['p'])){
   $page = $_GET['p'];
}
else if(isset($_GET['subaction'])){
   $page = 'news';
}

switch ($page) {
  case 'home': include('home/_home.php'); break;
  case 'news': include('news/_news.php'); break;
 // etc. 
}

A few changes here:
1) $page gets set to 'news' if a link with ?subaction exists.
2) It will go to page 'home' if there is no ?p in the link - as your code did. Array_merge() seems like a very inefficient way to do that, though — <acronym title='In My Humble Opinion'>IMHO</acronym>.

5 (edited by 2012-10-23 13:08:11)

Re: N00b questions: showing Full Story & Comments on the same page, etc.

(lKj), thank you very much! I tried your code, and it worked immediately! My gratitude is endless  http://cutephp.com/forum/style_emoticons/default/wub.gif http://cutephp.com/forum/style_emoticons/default/wub.gif http://cutephp.com/forum/style_emoticons/default/wub.gif   
I'll tweak my settings further, and if something is unclear I know the help is here http://cutephp.com/forum/style_emoticons/default/rolleyes.gif

UPD: I set up a lot of things today but another issue occurred: news pagination doesn't work. It has 'start_from' parameter so it points to the index page(( Could you please help me to correct this somehow? I tried this code but it's wrong and gives errors:
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>if(isset($_GET['p']))
{
   $page = $_GET['p'];
}
elseif(isset($_GET['subaction']))
{
   $page = 'news';
}
else(isset($_GET['start_from']))
{
   $page = 'news';
}</div>

6 (edited by 2012-11-01 08:44:09)

Re: N00b questions: showing Full Story & Comments on the same page, etc.

Bumping the issue! Could please somebody help me? I need my pagination links to point to the correct page on my site(((

7 (edited by 2012-11-01 14:27:17)

Re: N00b questions: showing Full Story & Comments on the same page, etc.

Oh, I never noticed that you edited your post.

Please try the following instead:

if(isset($_GET['p']))
{
   $page = $_GET['p'];
}
else if(isset($_GET['subaction']))
{
   $page = 'news';
}
else if(isset($_GET['start_from']))
{
   $page = 'news';
}

Re: N00b questions: showing Full Story & Comments on the same page, etc.

(lKj), thank you very much again, everything works correctly now, I just have to search for all the functions like Previous button (it differs a bit from the Next pagination button). It seems I understood how this function should work!

Re: N00b questions: showing Full Story & Comments on the same page, etc.

I'm happy you could change the code accordingly to your needs. You know where to find support in case of further problems. http://cutephp.com/forum/style_emoticons/default/smile.gif

Posts: 9

Pages 1

You must login or register to post a reply

CutePHP Forums → Problem Solving / Help & Support → N00b questions: showing Full Story & Comments on the same page, etc.



The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.