Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-02-20 21:07:57

kit
New Member
Registered: 2006-01-24
Posts: 4

[howto] Are you lost and confused with the default section?

Textpattern is lovely but the concept and use of the default section had me bamboozeled for days – actually I’m still confused. However, by adding the following code to each page to replace the title tag I can see:
  1. Which section the page uses
  2. Is it an article list or individual acticle
  3. Search results
  4. or Category List
  5. BUT cannot catch the Author list – how do you do it?

<code>
<title>
<txp:page_title separator=” &raquo; “ />
(section:
<txp:if_section name=”“> default
<txp:else /> <txp:section title=“1” />
</txp:if_section>
, type:
<txp:if_individual_article> individual article
</txp:if_individual_article>
<txp:if_article_list> <txp:if_search> search <txp:else /> <txp:if_category> category list <txp:else /> article list </txp:if_category> </txp:if_search>
</txp:if_article_list>
)
</title>
</code>

I hope this is of use to newbies other than myself.

(Putting this code in a form would improve its reusability)

Offline

#2 2006-02-21 00:00:39

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

Re: [howto] Are you lost and confused with the default section?

The URL would go this way: <code>http://yoursite.com/author/The+Author+Name</code> (clean URLs)

Nice idea, I use something similar to this in an article form; too many homegrown tags to post here however. The question of by author search lists… I suppose thier is a way, but I can’t think of a “currently present in the system” tag solution, but it should always be self evident in the current URL.

Offline

#3 2006-02-21 09:30:27

kit
New Member
Registered: 2006-01-24
Posts: 4

Re: [howto] Are you lost and confused with the default section?

It needs a “if_author” tag which would works the same way as “if_search” or “if_category”. Do you think this would be worthy of inclusion in later versions of textpatterm?

Offline

#4 2006-02-21 15:44:02

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

Re: [howto] Are you lost and confused with the default section?

In what live site circumstance would you use it?

Offline

#5 2006-02-21 19:08:10

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [howto] Are you lost and confused with the default section?

Making lists of articles by author, of course; you may not want the list to look like your default page. :)

Sure, it’s possible, I’m even sending in a patch.

Edit: and there’s a plugin that can be used in the meantime: rss_if_author

Last edited by Mary (2006-02-21 19:19:10)

Offline

#6 2006-02-21 19:22:19

igner
Plugin Author
Registered: 2004-06-03
Posts: 337

Re: [howto] Are you lost and confused with the default section?

Mary – I don’t remember seeing the patch posted to the dev list (but I’ve been busy with non-txp projects, so I might have missed it). Just curious what your solution was/is.

I needed this behaviour for www.bigtakeover.com and ended up hacking publish.php to check if author is passed in, and if so, to use a page “author”:

added around line 387 in publish.php:
I changed
<code> // by this point we should know the section, so grab its page and css $rs = safe_row(“*”, “txp_section”, “name = ‘“.doSlash($s).”’ limit 1”);
</code>

to

<code> // by this point we should know the section, so grab its page and css if($out[‘author’]) { $sp = ckEx(‘section’,‘author’) ? ‘author’ : $s; } else { $sp = $s; }

$rs = safe_row(“*”, “txp_section”, “name = ‘“.doSlash($sp).”’ limit 1”);
</code>

It’s probably not necessary to shift $s into a new variable ($sp), but I didn’t feel like tracing through the code to see if $s was used beyond that point, so just to be safe I didn’t simply overwrite the value of $s. Also note that I went for a fast and easy fix in this case – if the request is for an “author” page, use page named “author” if it exists, otherwise failover to the default.


And then my dog ate my badger, and the love was lost.

Offline

#7 2006-02-21 21:08:25

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

Re: [howto] Are you lost and confused with the default section?

I assign sections to authors, but yes, I do see your point; and yes, do be careful of the kids with the violin cases.

Offline

#8 2006-02-21 23:20:55

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

Re: [howto] Are you lost and confused with the default section?

A couple of questions:

Is rss_if_author intended to be used just in an article form, or can it be used in a page context as well, for author search page settings like if_search.

And, are there any holes in this approach that you can see?

<pre> function ras_if_author($atts, $thing) { global $pretext; extract(lAtts(array( ‘name’ => ‘’, ),$atts)); extract($pretext); if($name == ‘’) { return parse(EvalElse($thing, $author)); } else { return parse(EvalElse($thing, in_list($author, $name))); } }
</pre>

Offline

#9 2006-02-22 01:33:33

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [howto] Are you lost and confused with the default section?

> “…I don’t remember seeing the patch posted to the dev list…”

Haven’t sent it in yet, hence no use of past tense. ;) Just sending it in right now.

> “Is rss_if_author intended to be used just in an article form…”

Yeah, looks like it.

You want to global $author, rather than declare and use $pretext. They both return the same result, but $author doesn’t need to be extracted, so you save a function call.

Last edited by Mary (2006-02-22 01:33:57)

Offline

#10 2006-02-22 03:55:02

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

Re: [howto] Are you lost and confused with the default section?

Yes, works well that way, Thanks Mary.

Plugin link <a href=“http://textcastle.com/index.php?s=file_download&id=35”>Txp:ras_if_author</a>

Offline

#11 2006-02-22 13:27:22

kit
New Member
Registered: 2006-01-24
Posts: 4

Re: [howto] Are you lost and confused with the default section?

Thanks it works a treat. However, it would be nicer to have a easy way of redirecting category, search, and author lists to specific pages rather than use lashings of conditional tags in the default page. I almost gave up on txp when my beautifully styled home page colapsed into choas as I slowly discovered what else uses the default page. But that’s a problem for another thread.

Thanks for your help.

Last edited by kit (2006-02-22 16:07:09)

Offline

Board footer

Powered by FluxBB