Hoppa över navigering, gå direkt till textinnehållet



Textpattern plugin: glx_if

This plugin comes with 11 different conditional tags. Most of them could be used in either a page template or in a form.

glx_if_frontpage
If we are on the websites frontpage
glx_if_not_frontpage
If we are not on the websites frontpage, searchpage or category list. hmmm this could be the same as if_individual_article, well i cant remember why i did this one. But it is there for you to play with.
glx_if_section_frontpage
If we are on a sections frontpage
glx_if_not_section_frontpage
If we are not on the sections frontpage but in a section
glx_if_search
If the user are doing a search
glx_if_not_search
If a search not have been attempted
glx_if_category_list
If we are on a category list
glx_if_comments_open
If comments are open for this article
glx_if_comments_closed
If comments are closed for this article
glx_if_comments_closed_comments
If comments are closed for this article, but there are comments left before
glx_if_comments_count
Oputput text if comments are equal to something

Example

Below are some example of how the above tags could be used.

glx_if_frontpage

Output text only on the frontpage, this is used on the default page template

  1. <txp:glx_if_frontpage>
  2. <p>Welcome to this sites frontpage</p>
  3. </txp:glx_if_frontpage>

glx_if_not_frontpage

If we are not on the websites frontpage, searchpage or category list.

glx_if_section_frontpage

Output text if we are on a sections frontpage

  1. <txp:glx_if_section_frontpage>
  2. <p>Welcome to this section</p>
  3. </txp:glx_if_section_frontpage>

glx_if_not_section_frontpage

Output text if we are not on a sections frontpage but in a section.

  1. <txp:glx_if_not_section_frontpage>
  2. <p>We are in a section but not on its frontpage</p>
  3. </txp:glx_if_not_section_frontpage>

Note! To have this to work on my own page in combination with glx_if_section_frontpage, I had to put it above the glx_if_section_frontpage tag.

Say you have your search input on your archive page and want to have the search input above the search result, then you could use it like this on your default page template

  1. <txp:glx_if_search>
  2. <txp:search_input button="Search" size="15" wraptag="p" />
  3. </txp:glx_if_search>

If a search not have been attempted

  1. <txp:glx_if_not_search>
  2. <p>If no search has been done</p>
  3. </txp:glx_if_not_search>

Thanks to jase for the glx_if_not_search function.

glx_if_category_list

Output text if we are on a category list page

  1. <txp:glx_if_category_list>
  2. <p>Articles in this category</p>
  3. </txp:glx_if_category_list>

glx_if_comments_open

Oputput text if comments are open.

  1. <txp:glx_if_comments_open>
  2. <txp:comments_invite />
  3. </txp:glx_if_comments_open>

glx_if_comments_closed

Oputput text if comments are closed

Attribute
ingorecomments
Set this to false to ignore if comments have been left before. This is very handy if you want this tag to work with if_comments_closed_comments
default value: true

  1. <txp:glx_if_comments_closed>
  2. <p>Comments are closed for this article</p>
  3. </txp:glx_if_comments_closed>

glx_if_comments_closed_comments

Oputput text if comments are closed but there is comments left before.

  1. <txp:glx_if_comments_closed_comments>
  2. <li>Comments closed but there are <txp:comments_count /> old comments</li>
  3. </txp:glx_if_comments_closed_comments>

glx_if_comments_count

Oputput text if comments are equal to something

Attribute
value
What value to compare to, must be a int
default value: 0
operator
What to compare with, the following values are available

  1. equal_to
  2. not_equal_to
  3. less_than
  4. greater_than
  5. less_than_or_equal_to
  6. greater_than_or_equal_to

And some example of how to use glx_if_comments_count

Equal to 0 comments

  1. <txp:glx_if_comments_count operator="equal_to" value="0">
  2. <p>No comments yet, you could be the first.</p>
  3. </txp:glx_if_comments_count>

Equal to 1 comment

  1. <txp:glx_if_comments_count operator="equal_to" value="1">
  2. <p>There is only one comment</p>
  3. </txp:glx_if_comments_count>

More than 2 comments

  1. <txp:glx_if_comments_count operator="greater_than" value="2">
  2. <p>There are more than two comments</p>
  3. </txp:glx_if_comments_count>

Changelog

0.7

0.6.6

0.6.4

0.6.3

0.6.2

0.6.1

0.6

0.5

0.4

0.3

0.2

0.1

27. oktober 2004, 13:35
Oj. Den här kan vara riktigt användbar. Önskar att jag hade tid och ork att lägga in alla dina plugins.. men nu ska jag iaf lägga till den där log grejen du skrev om.
27. oktober 2004, 14:37
haha dem finns kvar tills sen med :)

Jag var tvungen att ha dessa funktioner för en ickeblogg sida jag håller på å donar lite med.
Lee sa,
1. november 2004, 19:17
Hi there,
just a small point, but the opening tag in your explanation above needs changing to _count.

Thanks again.
Lee

#
# No comments yet, you could be the first.
#
1. november 2004, 21:00
lee: ahh thanks for pointing that out, must rembember to change that in the plugins documentation too.
Lee sa,
2. november 2004, 00:53
Another “if”. If you don’t mind how about glx_comment_count, it would just return the number of comments an article has. 0 to n.

Then it would be poss to have:

Post a Comment

View comment(1)

View comments(2)

Do you have a paypal account? I’d like to buy you a beer.

Have a good weekend, Lee.
2. november 2004, 10:58
Yess i want that too :) And i have made a new version based on zem_link that does that.

<txp:glx_if_comments_count operator="equal_to" value="1">
<txp:glx_comment_link title="Comment '%s'">View comment</txp:glx_comment_link> (<txp:comments_count/>)
</txp:glx_if_comments_count>

and

<txp:glx_if_comments_count operator="greater_than" value="1">
<txp:glx_comment_link title="Comment '%s'">View comments</txp:glx_comment_link> (<txp:comments_count/>)
</txp:glx_if_comments_count>

This comment plugin is availible here but there is no documentation with it, and i hope Zem will add this to his zem_link.

ohh… beer sounds goood :P
2. november 2004, 11:54
Verkar vara ett trevligt plugin. Det jag ville säga något om var “automagiskt” (se under kommentar fönstret). Världens bästa ord som äntligen verkar fått lite fotfäste i Sverige. Inte en dag för sent. Undrar när Akademins ordlista ska lägga till det? :)
2. november 2004, 12:20
Ja jag älskar det ordet med, hehe vi får väll vänta och se :)
Lee sa,
2. november 2004, 13:59
Swap you a beer of your paypal contact details.

Lee
2. november 2004, 22:39
Lee: maybe i come to france instead :P Or you can send me a postcard, i love postcards :)
Daniel sa,
3. november 2004, 00:59
Thank you, so, so much. I think I was about to give up on TXP altogether. Sections, Pages, Forms, Articles, Article Lists, Custom Articles, Hidden Sections, Front Pages, layouts, ahhhhh.
19. november 2004, 18:58
this is one of my most-used plugins. i’m not sure what I would do now without it.

thank you.
8. december 2004, 13:59
Just wanted to say that use you plug.
I use the search part
Thanks :)

Welcome to stop by
Michael Byström Design
26. december 2004, 18:17

Hej Johan, tak for alle dine gode plugins. Jeg har et forslag til glx_if_not_frontpage: Du skrev her at du ikke vidste hvorfor at du havde lavet den, da den har samme effekt som if_individual_article.
Du kunne modificerer den til i stedet at fungerer som dens navn siger: Hvis man ikke er på forsiden i stedet for som nu, hvor den er sand, hvis man ikke er på forsiden, søgesiden eller i en kategoriliste.

Som det er nu er man nemlig, så vidt jeg kan se, f.eks nødt til at gentage sin kode to gange – en gang glx_if_not_frontpage og en gang glx_if_search, hvis man har noget der både skal vises når man ikke er på forsiden og når man er på søgesiden.
Det har jeg i hvert fald lige gjort. Måske er der en lettere løsning..

Men det var bare et forslag, endnu en gang tak for dit gode arbejde.

Håber det er ok med det danske..

Med venlig hilsen Tuk

31. december 2004, 00:17

Tuk, tack för din kommentar, känns alltid kul att folk uppskattar något som man gör :)

Jag ska ta och kika på glx_if_not_frontpage igen, och se om jag kan få den att fungera bättre. Men det är nog riktigt som du säger att man måste använda sig av glx_if_search för att nå den delen med och det känns ju inte riktigt korrekt.

Men jag vågar nästan säga att det inte blir förrän nästa år iaf :)

3. maj 2005, 01:24
For those having problems with section frontpages under the newest RC 3, use these two functions instead:

// the following two functions have been modified for clean_urls
// since is_article_list has been depreciated
function glx_if_section_frontpage($atts, $thing)
{
global $pretext, $_SERVER;
return ( (!empty($pretext[“s”])) && (empty($pretext[“c”])) && (strlen(substr($_SERVER[“SCRIPT_URL”], strpos($_SERVER[“SCRIPT_URL”],$pretext[“s”]) + strlen($pretext[“s”]))) 1) ) ? parse($thing) : “”;
}

(not sure how spacing is going to work) Since RC3 operates on CleanURL mode by default, and is_article_list is now returning null, the above just may work for you.
3. maj 2005, 01:30
The code tag isn’t working, so I have placed the code into my site’s media repository:

http://www.felocity.org/media/2005/05/02-glx_if_alteration/glx_if_functions.txt

Replace only the two glx functions that are in the txt file.
3. maj 2005, 08:14
Im not sure if is_article_list has been deprecated, I mean it still being used in some of txp main functions, for example in the comment_invite tag.

The only problems I heard of is that people are having problem with the glx_if_not_section_frontpage and glx_if_not_frontpage, if you look here I posted an alternative way to solve this, but as soon as i got some time over i will try to get the “not” tags to work too.

Thanks
Jamie sa,
5. maj 2005, 22:57
Is there any chance of adding section specific parameter to this?

ie:

glx_if section=”contact”

glx_if section=”help”

glx_if section=”files”

For some reason mdn_if has stopped working in the latest releases and I am used to basically having one page with conditionals outputing correct forms/articles for each setion as it is called.

Thanks Johan!
Jamie
7. maj 2005, 00:23
Hi Jamie, Thats sad to hear… im running mdn_if with no problem on two RC3 sites, i have no plans of adding this behavior to the glx_if plugin right now.

Maybe someone at the support forum knows a fix for you?
Beate sa,
17. maj 2005, 21:24
Is there an known bug in revision 370 with this plugin 0.6.4? On switching it on, there is a mistake:

Warning: extract(): First argument should be an array in /path/to/textpattern/publish/taghandlers.php on line 681.

Does anybody has this, too?
19. maj 2005, 09:19
Hi Beate,
What tag are you using that is causing this error?
nardo sa,
6. november 2005, 00:30
hi Johan,
on 4.0.2 don’t seem to be able to get glx_if_not_frontpage to work –

I want to use this to provide different styling for an author list
would it be possible to add glx_if_authorlist ?
Maxime sa,
8. november 2005, 21:42
Johan, thanks for your work.

Your plugin is very useful for me, in fact.
Marc sa,
20. november 2005, 04:45
Thanks for this nice plugin.

I await the final version impatiently.
David sa,
9. december 2005, 16:58
Great plugin. I use it every week.

David
Josh sa,
23. mars 2006, 07:19

Thanks for your plgin Yohan

kus sa,
11. mars 2007, 08:02

hhhmm

this plugins is no longer suported txp 4.0.4

Textpattern plugin: glx_countdownFrank är ivägen för Emma