Re: multiple page base

[email protected] (mikespub) Sat, 06 Sep 2003 10:24:00 GMT
Newsgroups gmane.comp.cms.xaraya.knowledge-base
Organization not much
Message-ID <[email protected]>
In article <bjbu5t$vcp$1-111RdWWlOxkOkXtL6OYfHgC/[email protected]>, [email protected] (Banzai) wrote:
>Hi, how do I do a multiple page on base ? 
>applying <!--pagebreak--> in user-main.xt doesnt work.
>Thanks
>
>Banzai
>
Hmmm, the <!--pagebreak--> trick only works when modules
can analyse content and break things up for themselves. In
short, only in articles at the moment :-)

However, you could change the base module to show several
"pages" too, e.g. by adapting the modules/base/xaruser/main.php
function to retrieve the page number and pass it on to the template :

function base_user_main()
{
// Security Check
    if(!xarSecurityCheck('ViewBase')) return;

// retrieve the page number
    if(!xarVarFetch('page', 'isset', $page,  NULL, XARVAR_DONT_SET)) {return;}
    if (empty($page)) {
        $page = 1;
    }

// adapt the page title if you want
    xarTplSetPageTitle(xarML('Welcome'));

// create a pager to let people navigate from page to page
    $pager = xarTplGetPager($page,
                            10, // your number of pages
                            xarModURL('base','user','main',
                                      array('page' => '%%')),
                            1);
// pass the current page number and the pager to the template
    return array('page' => $page,
                 'pager' => $pager);
}

In your user-main.xd template, you could then check on which "page" you are,
and show the appropriate content :

<xar:if condition="empty($page) or $page eq 1">
    This is page 1
<xar:elseif condition="$page eq 2">
    This is page 2
<xar:else />
    This is an unknown page
</xar:if>

<p>#$pager#</p>


Or if you don't want to have all "pages" in the same template,
you can tell the function to look for a different template
for each page :

function base_user_main()
{
..
// pass the current page number and the pager to the template
    $data = array('page' => $page,
                  'pager' => $pager);
// this will use the templates user-main-1.xd, user-main-2.xd, ...
    return xarTplModule('base', 'user', 'main', $data, $page);
}

Now you can create user-main-1.xd, user-main-2.xd etc.


Or if you want to use named pages (e.g. welcome, about, ...)
instead of numbered ones, you can use the same approach,
but use your own links to the different pages instead of
using the default pager :

index.php?module=base&page=welcome -> user-main-welcome.xd
index.php?module=base&page=about -> user-main-about.xd
..

HTH,

Mike.