Main
Index
Search
Posts
Who's
Online
Log
In

Home: Discontinued/Classic Products: Article Manager 2:
Template question

 

 


Ginslinger
User

Oct 20, 2006, 11:30 AM

Post #1 of 22 (5585 views)
Shortcut
Template question Can't Post

How does one go about using a different template for certain categories.


Dave
Staff / Moderator


Oct 20, 2006, 12:03 PM

Post #2 of 22 (5579 views)
Shortcut
Re: [Ginslinger] Template question [In reply to] Can't Post

There's two different ways to use different templates or html for different categories.

1) Use multiple publish rules and multiple templates

If you want to have completely different templates for each category or different sections this is the way to go.

The publish rule that creates category article lists is found here:
Admin > Publish Rules > Category Indexes

You can create an identical rule for each category or category group with a unique template and select the categories to include or exclude for each rule.

For example, you might have: "General Category Indexes" which publishes everything with the default category template and "Sports Category Indexes" which uses a sport category template.

2) Use TemplateIf tags in a single template

This is the simplest option. If there's only a few elements in your category article list page you want to change you can use templateIf tags to only display elements (or SSIs or PHP includes) for categories with a certain number, name, or even a field that you've defined. An example:

<!-- templateIf: $category.num$ == "8" -->
<!--#include virtual="/sports/headerBanner.html" -->
<!-- /templateIf -->

or if you've created an extra checkbox field in the field editor for category menus you might have:

<!-- templateIf: $category.isSportsRelated$ == "1" -->
<!--#include virtual="/sports/headerBanner.html" -->
<!-- /templateIf -->

You could even create a text box for your Categories which has the custom code right in the category editor, so it would be just a matter of having a placeholder in your default cagegory index template:

$category.customHeader$

If you wanted default code for when that field is blank, just drop in a templateIf that generates:

<!-- templateIf: $category.customHeader$ eq "" -->
<default html here>
<!-- /templateIf -->

I don't want to overwhelm you with options, but suffice to say there are many ways to do it. If you want to let us know exactly what you're trying to do we can recommend in detail what we think the best option would be.

One thing of note, as a developer you want minimize the number of templates as much as possible. Custom fields and templateIf's allow you to define the differences between your categories without being required to duplicate 90% of the code in a huge list of templates.

Let me know if that makes sense or if there's anything else you need.

Dave Edis - Senior Developer
interactivetools.com
 


Ginslinger
User

Oct 20, 2006, 12:11 PM

Post #3 of 22 (5574 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

Thanks for the reply. Really all I need to be able to do is apply author photos to certain categories for a reviews section. Sounds like using multiple publishing rules is the way to go. I'll give it a try but I am sure there will be more questions. Thanks once again.


(This post was edited by Ginslinger on Oct 20, 2006, 12:21 PM)


Theo
Project Manager / Moderator


Oct 20, 2006, 1:09 PM

Post #4 of 22 (5559 views)
Shortcut
Re: [Ginslinger] Template question [In reply to] Can't Post

Gins,

I think the solution may be very simple, without the extra work of creating new publishing rules.

First, a few questions:

- Were you planning to have the Authors as their own "category" as a subcategory of reviews, or would Author be selected on an individual article (in addition to and separate from Category)?
- Where were you planning to have the Author image appear: next to article summaries on index pages, on the top of category pages (if Authors are categories), on Article Pages?
- How many review Authors would you expect to have?

I want to find an elegant solution that doesn't require too many extra templates that are *almost* exactly like your other category templates. ;)


Theo Wiersma
Project Manager


Ginslinger
User

Oct 20, 2006, 1:33 PM

Post #5 of 22 (5555 views)
Shortcut
Re: [Theo] Template question [In reply to] Can't Post

Single author image for each author and it will display on the article page either at the top or bottom. What I would like to do is have it display right below the category breadcrumb.

Each author is a sub of the reviews category. Currently there are only four or five that would need to be setup for now.


Theo
Project Manager / Moderator


Oct 20, 2006, 1:57 PM

Post #6 of 22 (5549 views)
Shortcut
Re: [Ginslinger] Template question [In reply to] Can't Post


In Reply To
Single author image for each author and it will display on the article page either at the top or bottom. What I would like to do is have it display right below the category breadcrumb.

Each author is a sub of the reviews category. Currently there are only four or five that would need to be setup for now.


Thanks for the reply, Ginslinger! Okay, here's what I'd do:

1) Go to Admin > Database, click on "edit table..." for Categories.
2) Click "Add field"
3) For Field Label, put "Author Image (for Reviews)", and Field Name should be "authorImage". Set Field Type to Upload.
4) For Field Options, it should default to Single File (if not, select it). If desired, you could set some values for Input Validation, or rely on your defaults. Click SAVE.
5) Now open templates/articlePages/articlePage.html. Put this code where you want the author image to appear (customize the HTML to suit your tastes):

<!-- templateInsert : $category.authorImage$ -->

<!-- templateCell : category.authorImage.row -->
<img src="$file.WebUrl$" width="$file.width$" height="$file.height$" align="left">
<!-- /templateCell -->


Note that the HTML will only be generated when you actually have an Author Image. If there is OTHER html you want to include, to offset the placement of the image, it's a simple matter of adding it to a templateIf:

<!-- templateIf : $category.authorImage$ ne "" -->
<EXTRA HTML HERE>
<!-- /templateIf -->


6) Use FTP to upload your modified articlePage.html template, then go to your various Reviews categories and upload your author pics!


Thanks for your questions, Gins, this is really a great illustration of how you can do things slightly differently for one category with one simple field, rather that a completely different template and publishing rule!


Theo Wiersma
Project Manager


alfie.romeo
User

Nov 1, 2006, 8:37 AM

Post #7 of 22 (5425 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

hello

i do not have these menus items in my setup:

The publish rule that creates category article lists is found here:
Admin > Publish Rules > Category Indexes

i have:

Admin > Publishing

but nothing else after that. any ideas?

thanks


Dave
Staff / Moderator


Nov 1, 2006, 10:31 AM

Post #8 of 22 (5417 views)
Shortcut
Re: [alfie.romeo] Template question [In reply to] Can't Post

Sorry, Admin > Publishing is what we meant. Being a new product we're still getting used to what everything is named ourselves. I think an early beta called the menu "Publish Rules" and that's why we were mixed up.

Generally, though, it's not a bad idea to just click through and have a look at all the menu options to get an idea what's there.

Let us know if you need any more help. :)

Dave Edis - Senior Developer
interactivetools.com
 


alfie.romeo
User

Nov 1, 2006, 11:00 AM

Post #9 of 22 (5411 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

cheers dave

i have had a look through but can see nothing that would add, say a second header graphic to a template. is there any hard coding needed with this. do i have to add some code to one of the existing templates?

thanks


Dave
Staff / Moderator


Nov 1, 2006, 11:31 AM

Post #10 of 22 (5410 views)
Shortcut
Re: [alfie.romeo] Template question [In reply to] Can't Post

Yea, if you want to add a graphic to a template the way to do it would be to edit one of the templates and then either "Publish All" or click publish on the Publish Rule that uses that specific template.

Dave Edis - Senior Developer
interactivetools.com
 


alfie.romeo
User

Nov 1, 2006, 12:45 PM

Post #11 of 22 (5407 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

ok, i'm gonna need the tutorial for this. any idea when it will be ready? i can only see the tutorial for AM-1 on the website at the moment.


alfie.romeo
User

Nov 2, 2006, 8:20 AM

Post #12 of 22 (5389 views)
Shortcut
Re: [alfie.romeo] Template question [In reply to] Can't Post

hello

i am totally confused by this templates, publish rules thing.

can you give me a work through on what i should do to have a article page displaying a different header template, please. i think maybe if i was to see an example, i maybe able to figure this out

yours

alfie.


ross
Staff / Moderator


Nov 2, 2006, 10:16 AM

Post #13 of 22 (5378 views)
Shortcut
Re: [alfie.romeo] Template question [In reply to] Can't Post

Hi Alfie.

Just like anything else with Article Manager, you are going to have a whole bunch of different ways to have your articles have different headers Smile.

Were you going to break things down by category? What I mean by that is, are all the articles in one category going to have one header, and then all the articles in another category have a different header?

Or were you thinking of having just a few articles (from different categories) have one header, and then a few others have a second header?

Because Article Manager is so flexible, you can get either of these going, or even both I am pretty sure Smile. Of course, it would be best if I knew a little more about how you wanted things setup so I can get you on the right track.

I look forward to hearing from you Smile.
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Product Specialist
support@interactivetools.com

Hire me!  Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/



alfie.romeo
User

Nov 2, 2006, 10:38 AM

Post #14 of 22 (5375 views)
Shortcut
Re: [ross] Template question [In reply to] Can't Post

thanks ross

i have sent a support email in so that should explain everything. i don't need to do too much, just the basics and once i can see how this all works, i'm sure it'll be fine.

i just need category listings that link direct to articles and the ability to put a different header onto any page i (or the writer/user/editor/etc...) chooses.


LostCoder
User

Nov 2, 2006, 11:03 AM

Post #15 of 22 (5373 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

Hello,

In your post you had indicated the following:

This is the simplest option. If there's only a few elements in your category article list page you want to change you can use templateIf tags to only display elements (or SSIs or PHP includes) for categories with a certain number, name, or even a field that you've defined. An example:

<!-- templateIf: $category.num$ == "8" -->
<!--#include virtual="/sports/headerBanner.html" -->
<!-- /templateIf -->


I viewed the database field options (Admin > Database Editor > Table Editor ) and noticed there is a hidden field for categories called "num" which is the record number.

Is this the category number you are referring to? Would one be able to use the templateIf: option with this record number?

If so, how do i see the category number for each category, as this field is hidden.

If there is no way to do this, then I would actually have to create my own field, like "category.num", correct?

In the event i need to create my own field, is there a way to tell the system to autopopulate it by increasing the integer each time a new cat is created, or will i have to then go in and number each of my categories manually?

Thanks!

LC


Dave
Staff / Moderator


Nov 2, 2006, 11:21 AM

Post #16 of 22 (5369 views)
Shortcut
Re: [LostCoder] Template question [In reply to] Can't Post

LC, great question!

The quickest way to get the record number for a category is to click modify for it in the category editor (or mouse over the link) and then look at what's displayed in the address bar. You should see something like:

admin.cgi?action=categoryEdit&num=123

Where 123 is the record number for that category.

Dave Edis - Senior Developer
interactivetools.com
 


LostCoder
User

Nov 2, 2006, 12:03 PM

Post #17 of 22 (5366 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

wow... if only i had opened my eyes -- it was there the whole time -- i bet if i looked around a little more i'd find the answer to many more of life's questions :)

Thanks so much for the prompt reply!

LC

PS == for those looking to use PHP includes, i am using the following code to include 'category' specific elements.

<!-- templateIf: $category.num$ == "1" -->
<?php include("/home/zzzzzz/public_html/php_inc/myphpincludefile.htm"); ?>
<!-- /templateIf -->

This works like a champ, and personally I feel it blows the old method of creating an individual template for each article away.


MEKAEEL
User

Nov 20, 2006, 11:48 PM

Post #18 of 22 (5207 views)
Shortcut
Re: [Dave] Template question [In reply to] Can't Post

Hey Dave,

I think I'm missing something in your explanation. I set the new template and publish rule but how do I link the category from the menu to the published page?

I have a custom field called "Selected Articles" = Yes or No. And in the template I used the templateIf to show the SelectedArticles eq "Yes". Now in the Category Menu there is a link of "Selected Articles" but I can't connect this link to the published page of the template.

I tried going to the category options but I couldn't see anything there which helps, I kept looking at the publish rule page also for hours and couldn't see a thing either.

what am I missing?


ross
Staff / Moderator


Nov 22, 2006, 8:44 AM

Post #19 of 22 (5183 views)
Shortcut
Re: [MEKAEEL] Template question [In reply to] Can't Post

Hi Mikaeel.

Thanks for posting!

From the sounds of it, you are looking to have one of the links in your category list go to a custom page you created instead of the usual index page that Article Manager created you.

Does that sound right?

If so, it's actually quite easy Smile. When you setup the new publish rule you will have given it a "Placeholder Set Name". For my example, let's assume you called yours "myCustomRule". Just swap in the actual name where ever I use that. We'll also assume the name of the category you set this publish rule up for is called "The Category".

What you'll do is open up your /categoryMenus/categorMenu.html and find this bit of your code:


Code
<a href="$published.categoryIndex.url$">$category.name$</a>


and replace it with this:


Code
<!-- templateIf : $category.name$ eq "The Category" --> 
<a href="$publish.myCustomRule.url$">$category.name$</a>
<!-- /templateIf -->

<!-- templateIf : $category.name$ ne "The Category" -->
<a href="$published.categoryIndex.url$">$category.name$</a>
<!-- /templateIf -->


And that should get you going. What will happen here is that when the category menu is being created, it will check to see what category it is creating a link for. If it's for the special category that gets a new index page, it will swap in the URL for the new index. If it isn't, the regular link will be used. Make sure to republish your Global Menu and Category Menu publish rules from Admin -> Publishing

Let me know what you think Smile.
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Product Specialist
support@interactivetools.com

Hire me!  Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/



(This post was edited by ross on Nov 22, 2006, 7:42 PM)


MEKAEEL
User

Nov 22, 2006, 4:26 PM

Post #20 of 22 (5161 views)
Shortcut
Re: [ross] Template question [In reply to] Can't Post

thanks Ross,

that worked indeed :) but shouldn't webpath in

Code
 <a href="$publish.myCustomRule.webpath$">$category.name$</a>



be "url" instead?

For some reason I'm getting a long repeated url, like

www.mysite.com/artman2/publish/www.mysite.com/artman2/publish/mycat.index

and I tried changing webpath to url and it's the same.

any suggestions?


ross
Staff / Moderator


Nov 22, 2006, 7:46 PM

Post #21 of 22 (5153 views)
Shortcut
Re: [MEKAEEL] Template question [In reply to] Can't Post

Hi Mekaeel.

I definitely agree with you on that one. You'll want to be using .url and not .webpath. Sorry about that Blush. I fixed my post up.

My first though as to why it still isn't working though would be that you had set a custom folder for the publish rule to create its content and the URL in there was set as just

www.yoursite.com/myCustomFolder

You'll actually want that to be a full URL like this:

http://www.yoursite.com/myCustomFolder

Have a look and let me know if that gets you going again Smile.
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Product Specialist
support@interactivetools.com

Hire me!  Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/



(This post was edited by ross on Nov 22, 2006, 7:47 PM)


MEKAEEL
User

Nov 22, 2006, 11:51 PM

Post #22 of 22 (5146 views)
Shortcut
Re: [ross] Template question [In reply to] Can't Post

yep that worked Angelic thank you Ross!