Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-07-02 19:57:15

jrmartin
Member
From: California | Italy
Registered: 2013-03-07
Posts: 118
Website

Making a unique home page

Is there any way to detach a front page from the default so that the front page can be entirely different than a category page? I know I can use a slew of conditional tags, but boy would it be easier to use a whole new page template. I’ve searched this for hours, but maybe it’s so basic…

james

Offline

#2 2016-07-02 20:09:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,395
Website GitHub Mastodon Twitter

Re: Making a unique home page

Hi James,

I normally use the glx_f plugin found here

The tag is easy: <txp:glx_if_frontpage>... etc


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2016-07-02 20:38:41

jrmartin
Member
From: California | Italy
Registered: 2013-03-07
Posts: 118
Website

Re: Making a unique home page

When I tried to upload it, I got the message “I’m sorry. I’m afraid I can’t do that. I think plugin plugin_verify is no safe operation at this time.”

Offline

#4 2016-07-02 21:13:16

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Making a unique home page

I don’t think you need an outdated plugin, but I don’t understand your question. What do you mean with “front page from the default” and with a “category page”?

Or, why do you think that a condicional tag of an outdated plugin is better than <txp:if_category>?

Offline

#5 2016-07-02 21:16:46

jrmartin
Member
From: California | Italy
Registered: 2013-03-07
Posts: 118
Website

Re: Making a unique home page

The way I’m seeing it, Category pages and the front page uses the default page template. If I want to make a unique front page, there’s a crapload of code and conditional statements to add and juggle. I’d like a clean front page template to be used only for the front page, that’s all.

james

Offline

#6 2016-07-02 21:38:20

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Making a unique home page

You can create your own page template and assign it to the desired section.

Offline

#7 2016-07-02 22:00:27

jrmartin
Member
From: California | Italy
Registered: 2013-03-07
Posts: 118
Website

Re: Making a unique home page

So, what section is the front page?

Offline

#8 2016-07-02 22:42:04

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Making a unique home page

jrmartin wrote #300141:

So, what section is the front page?

default

Offline

#9 2016-07-02 22:48:15

jrmartin
Member
From: California | Italy
Registered: 2013-03-07
Posts: 118
Website

Re: Making a unique home page

I know. And that’s the problem. If I make the default page template into a layout for the front page, categories will also use that layout. I need to separate the front page from the default page template, I think…

Offline

#10 2016-07-02 22:49:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Making a unique home page

jrmartin wrote #300139:

The way I’m seeing it, Category pages and the front page uses the default page template.

Yes. And search results. And author pages. As you found out, if you use those and catgeories, that can result in a sometimes unwieldy front page template with a tonne of conditionals.

Unfortunately there aren’t many options. One is to farm as much as you can out to Forms to simplify the logic slightly:

<txp:if_category>
   <txp:output_form form="category_landing" />
</txp:if_category>
<txp:if_search>
   <txp:output_form form="search_landing" />
</txp:if_search>
...

Or you can nest them using <txp:else />, since it can’t be in both contexts at once:

<txp:if_category>
   <txp:output_form form="category_landing" />
<txp:else />
   <txp:if_search>
      <txp:output_form form="search_landing" />
   </txp:if_search>
</txp:if_category>
...

At least doing that, all your exceptions are out of the way in a fairly concise block and the rest of your default page template can be devoted to rendering your front page content.

Alternatively, you can redirect <txp:category /> URLs (including category1 and category2) to the current section so they can be handled by the current page template, by using the this_section="1" attribute or the section="some-section-name" attribute to send them to an arbitrary section. You can do the same with <txp:author /> links, and the <txp:search_input /> tag to redirect the output to a different template.

The downside to using categories in this manner is that you lose the clean URL syntax, as you get URLs like this:

example.org/section?c=category_name

If you can live with that, cool; a more svelte front page template is yours. If not, you can clean those up with .htaccess rules or the gbp_permanent_links plugin.

Thirdly, you could fashion your own category links, for example:

<txp:category_list>
   <a href="/cat/<txp:category title="0" />">
      <txp:category title="1" />
   </a>
</txp:category_list>

And then use an .htaccess rule to silently redirect them to example.org/some-section?c=category_name so nobody is any wiser that you have ugly URLs going on underneath. You can then process them in a dedicated page template assigned to some-section, which may well not even feature in your navigation at all: just a place to display category info.

Hope some of that helps.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#11 2016-07-02 23:28:55

jrmartin
Member
From: California | Italy
Registered: 2013-03-07
Posts: 118
Website

Re: Making a unique home page

Argh, that’s what I figured. Not easy. Thanks for your detailed explanation, Bloke.

james

Offline

#12 2016-07-03 04:05:40

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Making a unique home page

jrmartin wrote #300145:

Argh, that’s what I figured. Not easy. Thanks for your detailed explanation, Bloke.

A trick I have used in the past:

<txp:variable name="task" value="frontpage" />

<txp:if_category><txp:variable name="task" value="category" /></txp:if_category>

<txp:if_search><txp:variable name="task" value="search" /></txp:if_search>

<txp:if_author><txp:variable name="task" value="author" /></txp:if_author>

<txp:output_form form="task-<txp:variable name="task" />" />

You just put the code you need for each task in the proper miscellaneous form and you are good to go.

Offline

#13 2016-07-03 08:07:44

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: Making a unique home page

Hi

For me i allways use

<txp:if_section name="">

it works for me, the only thing is when putting links to category i use this :

<txp:category name="mycat" section="mysection" />

Cheers

Offline

#14 2016-07-04 08:01:44

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Making a unique home page

Bloke wrote #300144:

[categories …] Yes. And search results. And author pages…

More clarity on the magic default page. :)
It seems I often forget as much about Textpattern shamanism as I remember when caught up in my other pursuits.
Thanks Bloke!

Alternatively, you can redirect <txp:category /> URLs (including category1 and category2) to the current section so they can be handled by the current page template, by using the this_section="1" attribute or the section="some-section-name" attribute to send them to an arbitrary section. You can do the same with <txp:author /> links, and the <txp:search_input /> tag to redirect the output to a different template.

This is how I always handled it (because it’s how I learned to do it), so content was treated in context of the section it belonged to.

The downside to using categories in this manner is that you lose the clean URL syntax, as you get URLs like this: example.org/section?c=category_name... … [or] you can clean those up with .htaccess rules or the gbp_permanent_links plugin.

That latter approach using gbp_permanent_links is how I always did it, but I’m dropping gbp_permanent_links in all sites now in favor of core handling, so it will be homepage conditionals or .htaccess handling.

The end result is that I like category URLs ending up like this .../section/category/article-title, because it supports the mental model of hierarchical organization of content, even if it’s not really organized like that in a DB/relational way.

Dragonz, Michael … Nice options too!

Offline

Board footer

Powered by FluxBB