Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-09-14 17:23:23

New Member
Registered: 2023-09-14
Posts: 1

creating first page in Textpattern

Hey. Hey. I’m a complete beginner in Textpattern and I’m trying to create my first website. I have created four basic HTML templates which I styled using CSS. I will use these templates over and over again and will only change the content through articles (I guess?). So I have made 4 pages and 4 sections. In the pages, I invoke forms (with this tag <txp:output_form form=“xxx” />) and in the forms I call the content of the articles with the <txp:article_custom id=“xxx”> tag. I need me to enter a link to another article, and clicking on it would switch the content within one template. But sometimes I need to link to another template as well. Example: one of the templates is a product portfolio, when I click on a product I would like the page and its content to switch (but not all the content, for example the navbar will still be the same but the footer will be modified on some pages). How do I achieve this? Thank you in advance and have a nice day!


#2 2023-09-14 21:31:10

From: Leeds, UK
Registered: 2006-01-29
Posts: 11,281
Website GitHub

Re: creating first page in Textpattern

Hi and welcome to Textpattern. We’ll get you up to speed as fast as we can. It sounds like you’re nearly there already.

First of all, you might like to familiarise yourself with the semantic model. It’s outlined in Textpattern in two minutes and The Basics tutorial.

Making a page template per section is fine if all your sections are very different from one another. But if there’s any commonality, you can usually get away with fewer page templates, and assign one to many sections.

Then, inside your template code, you can either use conditional tags to take action if such -and-such is true (e.g. if section name is something, if the visitor is viewing a section list, or an individual article, etc) or you can use the power of the context-aware tags (such as txp:article) to automatically replace the tag with dynamic content based on the URL. You can mix and match tags however you like.

You would normally put the <txp:article> tag in your page template and then get it to format the article or list via a Form. That way, the article tag can react to the URL and display either:

  1. A list of articles in the current section being viewed (e.g. /products/)
  2. An individual article in the current section (e.g./products/widget-A)

<txp:article_custom>, on the other hand, is usually used for special effects like pulling content from one section into another. It is not as context-aware as the article tag.

Forms are also ideal for headers and footers and navigation bars because you can define how they work in one place – even add conditional tags around bits – and then include them in a template like you have been doing, via txp:output_form.

Generally, the fewer page templates you can get away with, the easier long term maintenance will be.

Last edited by Bloke (2023-09-14 21:36:35)

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp


Board footer

Powered by FluxBB