Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-29 09:20:26

wspence
Member
Registered: 2006-09-03
Posts: 84

Problem with article author form...

I have been using this form for a while and all of a sudden I am seeing issues with it showing my name twice on the author field.

Perhaps you guys have some insite as to what is going on…but I’m clueless here

The form looks like this and of course is set up to change by the author of the story.

By: 
<txp:if_article_author name="admin">
  <txp:email email="wspence@hoovision.com" linktext="Walt Spence" title="Send an Email" /><br /> Editor, Hoovision.com
</txp:if_article_author>
<txp:if_article_author name="uvasportsfanatic">
  <txp:email email="uvasportsfanatic@gmail.com" linktext="Dave, aka uvasportsfanatic" title="Send an Email" /><br /> Contributor and Webmaster of <a title="UVA Sports Fanatic" href="http://www.uvasportsfanatic.com/">UVA Sports Fanatic</a>
<txp:else />
  <txp:author />
</txp:if_article_author>

Now the Problem is that its rendering like this…

By: 
<a href="mailto:wspence@hoovision.com" title="Send an Email">Walt Spence</a><br />Editor, Hoovision.com

Walt Spence

In other words…showing my name twice. What’s up with that?

Thanks in advance!

ruud: changed formatting and removed irrelevant part of code

Last edited by ruud (2007-08-29 09:28:40)

Offline

#2 2007-08-29 09:34:16

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problem with article author form...

When the author is ‘admin’, the first condition is true, so that prints the wspence email link
The second condition is false, so the ‘else’ part of that condition is used, printing just the walt spence name.

Tricky to fix, because what you really want is:

<txp:if_article_author name="admin">
  <txp:email email="wspence@hoovision.com" ...
<txp:else />
  <txp:if_article_author name="uvasportsfanatic">
    <txp:email email="uvasportsfanatic@gmail.com" ...
  <txp:else />
    <txp:author />
  </txp:if_article_author>
</txp:if_article_author>

… but such tag nesting won’t work in TXP 4.0.x, unless you do it like this:

<txp:if_article_author name="admin">
  <txp:email email="wspence@hoovision.com" ...
<txp:else />
  <txp:output_form form="parse_workaround" />
</txp:if_article_author>

form ‘parse_workaround’:

<txp:if_article_author name="uvasportsfanatic">
  <txp:email email="uvasportsfanatic@gmail.com" ...
<txp:else />
  <txp:author />
</txp:if_article_author>

Offline

#3 2007-08-29 09:45:01

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

Re: Problem with article author form...

I wish we had and else_if statement just for cases like this!


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

Offline

#4 2007-08-29 09:48:40

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problem with article author form...

Or a switch/case/default statement.

Offline

#5 2007-08-29 10:56:48

wspence
Member
Registered: 2006-09-03
Posts: 84

Re: Problem with article author form...

So what you’re saying is this is just an error in parsing the code?

Offline

#6 2007-08-29 11:42:10

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problem with article author form...

No, it works as intended. You’re just using the wrong code ;)

See the second part of my first post for a solution.

Offline

#7 2007-09-04 03:21:22

wspence
Member
Registered: 2006-09-03
Posts: 84

Re: Problem with article author form...

to help me understand what exactly is causing my name to appear twice. i’m not sure how exactly i’m not using the code incorrectly.

Offline

#8 2007-09-04 07:24:14

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Problem with article author form...

Well, your code is wrong, because the second <txp:if_article_author>-conditional always retuns a value. And if publisher is “admin” there will be two <txp:author />-outputs.

So, answer is: Do what ruud pointed out to you earlier.

Cheers!

Offline

#9 2007-09-14 08:14:30

wspence
Member
Registered: 2006-09-03
Posts: 84

Re: Problem with article author form...

Thanks for the info. I still had to create two misc forms for this though to get it to look exactly the way I wanted. However, the ends justify the mean. Thanks so much!

Offline

Board footer

Powered by FluxBB