Textpattern plugin: glx_if
Posted 26. oktober 2004, 17:33 [Edited 28. september 2005, 22:51]
- Version: 0.7
- Download: glx_if.txt
- Textpattern forum thread: View discussion
- Active on this site: Yes
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
<txp:glx_if_frontpage><p>Welcome to this sites frontpage</p></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
<txp:glx_if_section_frontpage><p>Welcome to this section</p></txp:glx_if_section_frontpage>
glx_if_not_section_frontpage
Output text if we are not on a sections frontpage but in a section.
<txp:glx_if_not_section_frontpage><p>We are in a section but not on its frontpage</p></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.
glx_if_search
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
<txp:glx_if_search><txp:search_input button="Search" size="15" wraptag="p" /></txp:glx_if_search>
glx_if_not_search
If a search not have been attempted
<txp:glx_if_not_search><p>If no search has been done</p></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
<txp:glx_if_category_list><p>Articles in this category</p></txp:glx_if_category_list>
glx_if_comments_open
Oputput text if comments are open.
<txp:glx_if_comments_open><txp:comments_invite /></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
<txp:glx_if_comments_closed><p>Comments are closed for this article</p></txp:glx_if_comments_closed>
glx_if_comments_closed_comments
Oputput text if comments are closed but there is comments left before.
<txp:glx_if_comments_closed_comments><li>Comments closed but there are <txp:comments_count /> old comments</li></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
equal_tonot_equal_toless_thangreater_thanless_than_or_equal_togreater_than_or_equal_to
And some example of how to use glx_if_comments_count
Equal to 0 comments
<txp:glx_if_comments_count operator="equal_to" value="0"><p>No comments yet, you could be the first.</p></txp:glx_if_comments_count>
Equal to 1 comment
<txp:glx_if_comments_count operator="equal_to" value="1"><p>There is only one comment</p></txp:glx_if_comments_count>
More than 2 comments
<txp:glx_if_comments_count operator="greater_than" value="2"><p>There are more than two comments</p></txp:glx_if_comments_count>
Changelog
0.7
- Added documentation.
0.6.6
- This plugin should now work with TXP 4.01.
0.6.4
- Added glx_if_not_search written by jase
- glx_if_not_section_frontpage is now working
- Garett found out that DB prefixes wasnt working, it is now fixed.
0.6.3
- Still problems with glx_if_not_section_frontpage
0.6.2
- Experimenting with glx_if_not_section_frontpage
0.6.1
- Renamed glx_if_comments_eq to glx_if_comments_count
0.6
- New tag glx_if_comments_eq
0.5
- New tag glx_if_comments_closed_comments
- I also had to rebuild the glx_if_comments_close tag to make it work with glx_if_comments_closed_comments
- To glx_if_comments_closed you could now use the attribute ignorecomments=”false” to ignore if comments have been left before.
0.4
- Added if_comments_closed, from an idea by Compooter the TXP forum
0.3
- Fixed a bug with if_comments_open
0.2
- Added if_comments_open, from an idea by Jon Hicks at the TXP forum
0.1
- First release
Jag var tvungen att ha dessa funktioner för en ickeblogg sida jag håller på å donar lite med.
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.
#
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.
<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
I use the search part
Thanks :)
Welcome to stop by
Michael Byström Design
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
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 :)
// 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.
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.
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
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
Maybe someone at the support forum knows a fix for you?
What tag are you using that is causing this error?
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 ?