|
|
Rank: Devotee
Joined: 5/22/2008 Posts: 69 Location: Auckland, New Zealand
|
Hi All,
Still getting to grips with Umbraco. On my second day working with it but I've got a master template (which I guess work very similarly to master pages in .net 2 - is that a fair comment?) and a template page loaded in and working so it's good going so far this morning. I have a query though.
In my master template I've got all my head and body content. The body contains a very simple
header
main
footer
section of css div's. I want the header and footer to be consistent throughout the site so I figured it is best to set it up as a master. I've got my page loading into my main no problem. I want the users to be able to create pages however and then be able to specify page titles, keywords and descriptions. I've set up a property in my Master and in the template reference it like so:
<title><?UMBRACO_GETITEM field="pageTitle"/></title>
Problem is this is not accessible from the individual pages that use the template that is loaded INTO the master. :s Does that make sense? So it would appear to me at the minute, the only way I can get the user to be able to access this data is to put my head tags etc in the Main page template and dispose of using a master. Please tell me I'm wrong and there is a fantastic way I can access this property from my Main page template.
Lloyd
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,831 Location: MA, USA
|
There's a super-easy way to handle this in umbraco. First, keep your master/child templates as you've explained them. That's a great way to do it. You want to keep all the common stuff in master templates and the stuff that changes would go in children, typically. Then, in your templates you reference the document type properties you want to appear. For instance... I always create an "SEO" tab on my document types. On that tab I put at least the following two items: 'metaKeywords' of type textbox multiline 'metaDescription' of type textbox multiline I then add the following to the <head> section of my master template... Code: <meta name="Keywords" content="<?UMBRACO_GETITEM field="metaKeywords"/>"/> <meta name="Description" content="<?UMBRACO_GETITEM field="metaDescription"/>"/>
The actual values are picked up from the page that is being displayed to the website visitor. The 'recursive' option of GETITEM can also be handy in these situations. cheers, doug.
MVP 2007-2009 - Percipient Studios
|
|
Rank: Devotee
Joined: 5/22/2008 Posts: 69 Location: Auckland, New Zealand
|
Did the job. Didn't realise you could reference the 'containers' in another template. Thanks. :)
|
|
Rank: Newbie
Joined: 7/17/2008 Posts: 6 Location: Glasgow
|
Hi,
Just as a follow up to this, is there a way that I can specify properties at a global level. For example on a site I am building I have a footer area with address information for the company which I would like editors to be able to change through the CMS.
The solution above is great for SEO where you may want to set different values based on the type of page or for a page title where it could be different everytime. However, I want to be able to set a property once and have it used throughout the site.
Is there a way that I can set the address information centrally and have it picked up by the Master template and therefore used on every page?
I was thinking that creating a macro with a "content" property for the master template could be a solution here but that would involve the editor having to tweak the master to change the address which isn't ideal.
Any ideas or links to examples would be appreciated!
Cheers, Robert
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,831 Location: MA, USA
|
Simple to do... let's suppose you have this kind of content structure: Code:CONTENT - Home -- Products -- Services -- etc. Let's further suppose your Home document type has a property called "Site Name" with an alias of "siteName". Show the current page's name followed by a dash followed by the Site Name in the <title> of every page on your site, just do the following... Code:<?UMBRACO_GETITEM field="pageName"/> - <?UMBRACO_GETITEM field="siteName" recursive="true"/> The recursive="true" flag is the key. What that does is look for the field on the current page. If it isn't there, look to it's parent. Keep looking up the content node tree until you either find it or run out of nodes to look at. cheers, doug.
MVP 2007-2009 - Percipient Studios
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi, Do as Doug already suggested, you could indeed 'recursive properties' for this. And this is great if you need to differentiate info on different pages of the site. But there's also another technique which Doug has used before (Having static data on all pages which is updateable through the content section). He creates a separate section for this, adds all configuration data needed for the entire site and uses a macro that fetches that data on all pages (Most probably from within the master template). He's made a post on this, I'll see if I can dig this up. Edit: Here's the link about Doug's approach of a 'configuration' node It's just another approach. Both work fine, but have slightly different goals. Hope that helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Newbie
Joined: 7/17/2008 Posts: 6 Location: Glasgow
|
Fantastic, thank you both.
I've decided to go for the first option just now as I don't have too many global properties.
In future though I think I'll investigate the use of a config page as this will probably be better suited to a site with a lot of global properties.
Cheers, Robert
|
|
|
Guest |