Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
Re: Making a unique home page
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
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,473
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
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,473
Re: Making a unique home page
You can create your own page template and assign it to the desired section.
Offline
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,473
Re: Making a unique home page
Offline
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
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.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Making a unique home page
Argh, that’s what I figured. Not easy. Thanks for your detailed explanation, Bloke.
james
Offline
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