Re: Tutorial-like documents

[email protected] (mikespub) Tue, 18 Nov 2003 19:45:33 GMT
Newsgroups gmane.comp.cms.xaraya.ui
Organization not much
Message-ID <[email protected]>
In article <bpdfnv$s7s$1-111RdWWlOxkOkXtL6OYfHgC/[email protected]>, [email protected](Benoit) wrote:
>
>Hello,
>
>I'm currently Xaraya-izing the web site of the NGO i'm working for.
>
>I'd like to integrate documents to the article module, the way tutorials
>are integrated in xaraya.com website. Meaning, i'd like to divide them
>into various parts, having URL's like: articles/165?page=2
>
>But i don't see the way to split documents in the 0.914 release. Did I
>miss something in the documentation? How is that done?
>
By using a special tag <!--pagebreak--> in your article text where you
want your page breaks :-)

If it's not included in the documentation, perhaps a patch/bug/feature
report would be nice at bugs.xaraya.com...

>Moreover, I'd like to have, for a particular category, or for a
>particular publication type, an option to display directly the content
>of a publication (instead of just the summaries) in the case when there
>is ony *one* document in the category. Is there a way to do that? Where
>do I have to put my nose if i want to code that kind of feature?
>
>Cheers,
>Benoit

In the user-view template for articles, $number gives you the number of
articles shown. And in the user-summary-<pubtype> templates, you
can also use the $body variable if you want.

However, before you get your hopes up and start changing the articles
templates, you should know that the templates are executed "from the
inside out", so the summaries are filled in first, and then the view is
built around the summaries.
Which means that -by default- when the summaries are filled in,
you won't know yet if you will have more than 1 summary or not,
i.e. you won't know then if you'll want to show the body or not.

Having said all that [and scared you away forever, probably :)], it would
be pretty easy to change the modules/articles/xaruser/view.php file
so that it passes the number of articles found to the user-summary-*.xd
template.
The main loop for the articles starts at line 500 of that file :

    $number = 0;
    foreach ($articles as $article)
    {
        ...

        // fill in the summary template for this article
        $template = $pubtypes[$article['pubtypeid']]['name'];
        $columns[$col][] = xarTplModule('articles', 'user', 'summary', 
$article, $template);
        $number++;
    }

You could for instance add :
    $article['numarticles'] = count($articles);
inside the loop, and use the $numarticles variable in your summary template
to decide whether to show the body or not :
<xar:if condition="$numarticles lt 2">
    <!--- let's show the body here too --->
    #$body#
</xar:if>

Or another strategy here might be to redirect the user to the display of
that article - which might be a bit confusing at first, but allows your
users to see the comments, ratings etc. for that article immediately.

YMMV,

Mike.