Collections of Lists Options
tobinharris
Posted: Saturday, September 16, 2006 3:01:49 PM
Rank: Newbie

Joined: 9/16/2006
Posts: 2
Hi there,

I've just started playing with Umbraco, what a cool piece of kit!

I've installed the Wizard plugin and I now have a basic site with news that looks good.

My next step is to add a portfolio and a blog. So, my site will have the following:

- News Items
- Portfolio Items
- Blog Postings

Rather than creating document types, templates and xslt files for each of these, I wandered if I could use a single mechanism for them all? On a data level, they all hold similar information:

- A heading/name
- Some teaser html
- The main body html
- A teaser image that appears when the items are listed (optional)
- tags

So I figure I could have one DocumentType called "List" and another called "List Item" ?

But where to go from here? Do I have to then go on to create a template, a macro, xslt for each type? Is there an easier way to do this?

Many thanks

Tobin
tobinharris
Posted: Tuesday, September 19, 2006 9:54:00 AM
Rank: Newbie

Joined: 9/16/2006
Posts: 2
Ok, I sorted this out myself. For anyone who's interested, here's the approach I've taken. The benefits of this approach are that you can use *ONE* macro, XSLT file & Document Type to maintain and display lots of types of information. The types I'm using are:

- News Items
- Blog Entries
- Work Portfolio Entries
- Product & Service descriptions

1. Create 2 new document types called List and List Item.
2. Add a new text property to List Item doc type called "ItemType". In your content you later set this to blog, news, portfolio, service etc.
3. Create your "DisplayList" macro, with a parameter "ItemType", using a DisplayList.xslt file.
4. In the XSLT, you can filter your select to match items of a particular type.

This declares the parameter...

<xsl:variable name="category" select="/macro/listCategory"/>

Then this fetches list items of a particular category...

<xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]/descendant::node[@nodeTypeAlias = 'wwList']/child::data[@alias='listCategory' and text()=$category]/parent::node/node">

I basically adapted the code from the Wizard Generators news items, and just made it more flexible.

Calling the macro looks like this....

<?UMBRACO_MACRO macroAlias="DisplayNews" numberOfItems="3" listCategory="portfolio" showImage="false" showTitle="true" showTease="true" showDate="false"/>

The end result is that I can have many types of thing all displayed using the same template but not all in the same list.

Cheers

Tobin
Tobin
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.