Custom homepage Plone 3

6 messages Options
Embed this post
Permalink
Sanders

Custom homepage Plone 3

Reply Threaded More More options
Print post
Permalink
I created a site for moaweb.nl in Plone 3 with a custom homepage.
It's based on 4 columns where the client can maintain the content completely TTW.

In the custom template I created the following code for the events:
<ul>
{% for n in evenementen %}
<li>{{n.titel|safe}}</li>
{% endfor %}
</ul>
Overzicht evenementen »

How can I adjust this code so that:
- only the X most recent items in folder X are shown?

I tried different pieces of python code but only ended up with no content shown at all.
My understandig of this language is very limited and I'm definetly stuck here.

Maybe someone can  give me a push in the right direction?

Greetings,
Nique
MichaelT

Re: Custom homepage Plone 3

Reply Threaded More More options
Print post
Permalink
In the freearch theme they do this:

 def recently_published_news(self):
        context = self.context
        catalog = getToolByName(context, 'portal_catalog')
        results = []
        for r in catalog(portal_type='News Item',
                         review_state='published',
                         sort_on='Date',
                         sort_order='reverse',
                         sort_limit=2,):
            results.append(dict(date=r.Date,
            year=DateTime(r.Date).year(),
            month=DateTime(r.Date).month(),
            day=DateTime(r.Date).day(),
            news_obj=r.getObject(),
            url=r.getURL(),
                                title=r.Title,
                                description=r.Description,
                                ))
        return results

Hope that helps.
Sanders wrote:
I created a site for moaweb.nl in Plone 3 with a custom homepage.
It's based on 4 columns where the client can maintain the content completely TTW.

In the custom template I created the following code for the events:
<ul>
{% for n in evenementen %}
<li>{{n.titel|safe}}</li>
{% endfor %}
</ul>
Overzicht evenementen »

How can I adjust this code so that:
- only the X most recent items in folder X are shown?

I tried different pieces of python code but only ended up with no content shown at all.
My understandig of this language is very limited and I'm definetly stuck here.

Maybe someone can  give me a push in the right direction?

Greetings,
Nique
MichaelT

Re: Custom homepage Plone 3

Reply Threaded More More options
Print post
Permalink
Not sure my response below was accepted, so I'm replying now that I am a subscriber.

MichaelT wrote:
In the freearch theme they do this:

 def recently_published_news(self):
        context = self.context
        catalog = getToolByName(context, 'portal_catalog')
        results = []
        for r in catalog(portal_type='News Item',
                         review_state='published',
                         sort_on='Date',
                         sort_order='reverse',
                         sort_limit=2,):
            results.append(dict(date=r.Date,
            year=DateTime(r.Date).year(),
            month=DateTime(r.Date).month(),
            day=DateTime(r.Date).day(),
            news_obj=r.getObject(),
            url=r.getURL(),
                                title=r.Title,
                                description=r.Description,
                                ))
        return results

Hope that helps.
Sanders wrote:
I created a site for moaweb.nl in Plone 3 with a custom homepage.
It's based on 4 columns where the client can maintain the content completely TTW.

In the custom template I created the following code for the events:
<ul>
{% for n in evenementen %}
<li>{{n.titel|safe}}</li>
{% endfor %}
</ul>
Overzicht evenementen »

How can I adjust this code so that:
- only the X most recent items in folder X are shown?

I tried different pieces of python code but only ended up with no content shown at all.
My understandig of this language is very limited and I'm definetly stuck here.

Maybe someone can  give me a push in the right direction?

Greetings,
Nique
vedaw

Re: Custom homepage Plone 3

Reply Threaded More More options
Print post
Permalink
In reply to this post by Sanders
You can also look at the two different kinds of homepage views in this
theme:

svn co https://svn.plone.org/svn/collective/plonetheme.guria
plonetheme.guria

(Check it out from subversion). One homepage view pulls in the contents of a
Page content type, and one pulls in either a Page or a Collection using a
slots-based solution. The slots solution might work for you here. Using
Collection criteria, you should be able to state how many items you want to
show, rather than doing it programmatically.

Cheers,

- Veda



On 9/3/09 5:57 AM, "Sanders" <[hidden email]> wrote:

>
> I created a site for moaweb.nl in Plone 3 with a custom homepage.
> It's based on 4 columns where the client can maintain the content completely
> TTW.
>
> In the custom template I created the following code for the events:
> <ul>
> {% for n in evenementen %}
> <li> {{n.url|safe}} {{n.titel|safe}} </li>
> {% endfor %}
> </ul>
> /MOA/evenementen-en-agenda/evenementen-agenda Overzicht evenementen »
>
> How can I adjust this code so that:
> - only the X most recent items in folder X are shown?
>
> I tried different pieces of python code but only ended up with no content
> shown at all.
> My understandig of this language is very limited and I'm definetly stuck
> here.
>
> Maybe someone can  give me a push in the right direction?
>
> Greetings,
> Nique


_______________________________________________
UI mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/ui
Sanders

Re: Custom homepage Plone 3

Reply Threaded More More options
Print post
Permalink
In reply to this post by MichaelT
Tnkz!I'm still playing with the code but I'm definitely a step further.
Geir Bækholt-2

Re: Custom homepage Plone 3

Reply Threaded More More options
Print post
Permalink
In reply to this post by Sanders
Sanders wrote:

> In the custom template I created the following code for the events:
> <ul>
> {% for n in evenementen %}
> <li> {{n.url|safe}} {{n.titel|safe}} </li>
> {% endfor %}
> </ul>
> /MOA/evenementen-en-agenda/evenementen-agenda Overzicht evenementen »

What sort of syntax is this? php,asp?
I recommend you take a look at the documentation section on plone.org as
a start.

Plone's templates use xml attributes for their dynamic parts. Like you
can see examples of here:
http://docs.zope.org/zope2/zope2book/source/ZPT.html

best regards.


--
Geir Bækholt
http://www.jarn.com


_______________________________________________
UI mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/ui