Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-26 18:52:24

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Existing tags with improved functionality

So far this forum had tended to deal with new tags and how to use them. I’m going to discuss existing tags that have been improved and how you can replace your tired old plug-in tags with them.

<code><txp:if_section><txp:else /></txp:if_section></code> has had comma-separated list functionality added.

You can use <code><txp:if_section name=”“></code> to query if you are on the front-page so this tag can replace “glx_if_frontpage”. Using the <code><txp:else /></code> tag as well gives you the same as “glx_if_not_frontpage”.

You can also use <code><txp:if_section name=“section1,section2,section3”></code> to query a list of sections. This is the comma-separated list in action. This can replace “ob1_if_section” and “mdn_if_section” plug-in tags. I don’t use either of these plug-ins anymore.

<code><txp:if_category><txp:else /></txp:if_category></code> has had comma-separated list functionality added as well plus the odd surprise.

You can use <code><txp:if_category></code> without any attributes to query if you are in a category listing. This would replace the “glx_if_category_listing” tag and because you can use it with the <code><txp:else /></code> tag it can also replace the “glx_if_not_category_listing” tag as well.

<code><txp:if_category name=“category1,category2,category3”></code> will query a list of categories. This is the comma-separated list again. You can replace most of your “if_category” plug-in tags with this and don’t forget the <code><txp:else /></code> tag here as well which gives you “if_not_category” functionality too.
<br />
A tag which isn’t very old but isn’t very new either and doesn’t receive much publicity is <code><txp:if_search><txp:else /></txp:if_search></code>. If you still allow your search results to use the front-page this is very handy for separating them from your normal front-page code so you can style them differently.
<br />
My own preference is to send search results to their own section as I prefer my front-page to be nothing else but my front-page. Combined with the trick I discussed here of making your category lists remain in the same section as the articles are in, keeping your front-page virginal is now pretty easy. (That should get the search engines pumping. :grin:)
<br />
Now that the “title” attribute has been added to both <code><txp:section /></code> and <code><txp:category /></code> you can pretty much replace all your “ob1_title” tags.
<br />
The newer <code><txp:site_url /></code> tag is extremely useful for me because it means I can design page and form templates on my site for any themes I am porting which will work on your site. Now there’s no need to deliberate on whether to use a “relative” or “absolute” path in your menus and links. <code><txp:site_url />archives</code> is the same as <code>http://mysite.com/archives</code>, in other words the FULL path. Very handy methinks.

Last edited by thebombsite (2005-11-28 03:28:44)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#2 2005-11-27 00:22:06

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

Re: Existing tags with improved functionality

Some great tips Stuart and concisely put. I downloaded one of your newer ports a few weeks ago to digest some of the tags you were using and gleaned much of this from those. Many many improvements. Every plug in that can be depreciated the better in my book. ‘Cause that means txp is moving’ right along. :)

Thanks for the recent write ups in this forum section. Very useful. I wish this section had been around when I first started using.

Offline

#3 2005-11-27 18:44:33

aesop1
Archived Plugin Author
Registered: 2004-09-19
Posts: 142

Re: Existing tags with improved functionality

Yes, thanks, Stuart. I think the TXP community really benefits from posts like this.

Offline

#4 2005-11-28 03:18:16

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Existing tags with improved functionality

Perhaps a summary of changes to tags (much like this) with each release could be set up, the trick would be making it easy to find, and easy to recognise for what its intended for.

Offline

#5 2005-11-28 19:37:20

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Existing tags with improved functionality

thebombsite wrote:
bq. Now that the “title” attribute has been added to both <txp:section /> and <txp:category /> you can pretty much replace all your “ob1_title” tags.

Stuart, can you explain that a little more?

I did always use ob1_title inside the <title></title> element.

But as far as I understand your words, you were using it to output the section/category title in page templates, am I right?
if that was what you were doing, it was very clever. I didnt never think to use ob1_title to output section/category titles in page templates.

But as you said, now it’s possible to use txp:section and “title” attribute.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2005-11-29 00:45:18

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Existing tags with improved functionality

Yes I used to use it for page titles and for the “title” in the head, but I also used it for a hidden “h1” for Google purposes. Now we have the title attribute for <code><txp:section /></code> and <code><txp:category /></code> plus the <code><txp:page_title /></code> tag it’s not really needed and I believe they can be used in the head as well (not category).

Last edited by thebombsite (2005-11-29 00:55:33)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#7 2005-11-29 02:28:00

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

Re: Existing tags with improved functionality

hmm, interesting discussion that raises valid points.

@thebombsite

The <txp:section /> can indeed be used for the < title /> tag (in the head of the doc). I do use it for sections:

<title><txp:section title="y" /> | <txp:sitename /><title>

But I still have a hard time eliminating the use of the ‘ob1_title’ plugin completely.
The problem with the <txp:page_title /> tag: one can only use it this way: ‘site name’ ‘separator’ ‘article-title’. I prefer to put this as ‘article-title’ ‘separator’ ‘site name’ (more SEO friendly, also handy if someone bookmarks an article). ‘site name’ is not a problem but <txp:title />, which generates the article title, doesn’t work outside of the body.

(it might be a feature request to improve the <txp:page_title /> to work both ways).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#8 2005-11-29 05:56:27

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Existing tags with improved functionality

Agreed. It would be nice to be able to switch <code><txp:page_title /></code> around. Although you can use <code><txp:sitename /></code> in the <code><title></title></code> you can’t use the <code><txp:title /></code> tag so an improvement to that first tag would be handy. Once you get inside the <code><body></code> though you can use all of them in whatever order you like, so as I mentioned earlier, I used a hidden “h1” at the top of the page using these tags instead of “ob1_title” tags which I used to use. I’m not suggesting that the new or improved tags can replace every instance of a plug-in tag but in my own case I no longer use “glx_if” (though there are other tags in there but I’ve never needed them), any “if_section” or “if_category” plug-in, “ob1_title” or “rss_suparchive”. So that’s 4 plug-ins less. :)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#9 2005-11-29 15:22:31

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Existing tags with improved functionality

thebombsite wrote:

and I believe they can be used in the head as well (not category).

<txp:category /> can be used in the head as well :)

Offline

#10 2005-11-29 16:03:54

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Existing tags with improved functionality

thebombsite wrote:

you can’t use the <txp:title /> tag so an improvement to that first tag would be handy.

Maybe, this could work:

In the <head>:

<code><txp:if_individual_artitle>
<txp:article pgonly=“1” />
<title><txp:title /> | <txp:sitename /></title>
<txp:else />
<title><txp:sitename /></title> <!—or whatever you want to use as title —>
</txp:if_individual_article></code>

I havent tested this, because I dont have a test TXP installation (time to have one).
I dont know if <txp:article pgonly="1">, in individual_article context, spreads all article variables.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#11 2005-11-29 16:19:24

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

Re: Existing tags with improved functionality

> thebombsite wrote:

>You can use <code><txp:if_section name=”“></code> to query if you are on the front-page so this tag can replace “glx_if_frontpage”. Using the <code><txp:else /></code> tag as well gives you the same as “glx_if_not_frontpage”.

Hi Stuart,
I have tried to replace my code with your suggestion but it just does not work…
I have this in my default template:
<code><txp:glx_if_frontpage><txp:output_form form=“front_page” /><txp:else /><txp:output_form form=“any_page” /></txp:glx_if_frontpage></code>
If I change the <code>glx_if_frontpage</code> with <code>txp:if_section name=”“</code> the front page just shows the content of a non styled ?pg=1 as opposed to a styled /index.php. (I know this might sound confusing…:)

I wish we can work without the plugins but in this particular case i think that glx_if_frontpage offers a functionality which is far beyand the txp:if_section name=”“ which comes with txp.


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

Offline

#12 2005-11-29 23:56:25

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

Re: Existing tags with improved functionality

@ maniqui

Unfortunately, it is a no go on my side. This outputs the whole article in the <head> of the page.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB