1 (edited by 2013-11-07 03:40:42)

Topic: Problem with function

Hello ,

I am trying to include the script in my root/index.php , the CN is in root/news/

I use function in my index.php so i used :

function news()
{
    // ------ START NEWS --------
    //include
    //end include
    require_once("news/core/init.php");
    $pw = REQ('pw');
    $pw['number'] = "3";
    if ($pw['PHP_SELF']) $PHP_SELF = $pw['PHP_SELF'];
    if ($pw['template']) $template = $pw['template'];
    if ($pw['start_from']) $start_from = $pw['start_from'];
    if ($pw['number']) $number = $pw['number'];
    if ($pw['archive']) $archive = $pw['archive'];
    if ($pw['category']) $category = $pw['category'];
    if ($pw['ucat']) $ucat = $pw['ucat'];
    if ($pw['sortby']) $sortby = $pw['sortby'];
    if ($pw['dir']) $dir = $pw['dir'];
    if ($pw['page_alias']) $page_alias = $pw['page_alias'];
    if ($pw['tag']) $page_alias = $pw['tag'];
    if ($pw['user_by']) $user_by = $pw['user_by'];
    if ($pw['static']) $static = $pw['static'];
    if ($pw['reverse']) $reverse = $pw['reverse'];
    if ($pw['only_active']) $only_active = $pw['only_active'];
    if ($pw['no_prev']) $no_prev = $pw['no_prev'];
    if ($pw['no_next']) $no_next = $pw['no_next'];   
    include("news/show_news.php");
    // ------ END NEWS --------
}

that is called as : http://xxxx.com/index.php?op=news

but all the parameter like : $number or others are not working ??? it's show me all the news and not only a specific number ?

What's wrong ? something wrong because i am in index.php?op=news already ?

2 (edited by 2013-11-07 04:49:07)

Re: Problem with function

basicaly something  like that will no works fine ( the parameter $number will no works ) :


<?php
function news()
{    // ------ START NEWS --------
        require_once("news/core/init.php");
    $number = "3";
        include("/var/www/news/show_news.php");
    // ------ END NEWS --------
}
function home()
{
?>
&lt;span id=&quot;faq&quot;&gt;NEWS LOAD&lt;/span&gt;
<?php
}
    switch ($_REQUEST['op']){
        case 'index':
            home();
            break;
        case 'news':
            news();
            break;               
        default:
            home();   
    }
?>

Re: Problem with function

please any idea ? there is a trick with SELF_PHP and QUERY... ? or something other ?

Re: Problem with function

Try $_GET['number'] = $number;
before
include("/var/www/news/show_news.php");

Best regards,
CN Support team

Re: Problem with function

Try $_GET['number'] = $number;
before
include("/var/www/news/show_news.php");

Alright it's working https://cutephp.com/forum/style_emoticons/default/smile.gif

Thank you admin <3 your dev smile