BlogHarbor Home Page
FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  UsergroupsRSS   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
if/then code for article / main page/ category templates
 
Post new topic   Reply to topic    BlogHarbor Community Forum Index -> Beginner's Lounge
View previous topic :: View next topic  
Author Message
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Tue Aug 02, 2005 9:01 am    Post subject: if/then code for article / main page/ category templates Reply with quote

On my blog I'm posting articles I write, and reprinting articles from other sources (with appropriate permissions, of course!).

On articles I write myself, I'd like to have the post header to read:

Article Title
posted by [author] on [date]

On reprints, I'd like it to read:

Article Title
Reprinted on (or by Guest Author, etc) [date]

I've seen various code snippets posted here, and I think that using something like:
Code:
{if author is }
me
{then}
do the first option
{else}
do the second option
{/if}


I'm having trouble getting a grip on the syntax. A potential problem I see with this is that the Author is ALWAYS going to be me. I guess I can set up a 2nd "dummy" author account, and reprint from there.

Any assistance is appreciated.
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Tue Aug 02, 2005 9:59 am    Post subject: Re: if/then code for article / main page/ category templates Reply with quote

I'm having trouble getting a grip on the syntax. A potential problem I see with this is that the Author is ALWAYS going to be me.

If that is true, then it simply won't be possible to use a macro like {if author eq "yourusername" }, you would need to make a decision on something else, perhaps the title.

I guess I can set up a 2nd "dummy" author account, and reprint from there.

That would work. You could also preface titles with a marker like "Reprint: ", then use something like this:

Code:
{if title REGEXP "Reprint: "}
   The title contained the text "Reprint: "
{else}
   This is not a reprint...
{/if}


Hope this helps get you started... FYI, there's no THEN in the macro code, you just need to open with an IF and put the stuff you want to do after that.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Tue Aug 02, 2005 11:02 am    Post subject: Re: if/then code for article / main page/ category templates Reply with quote

john wrote:
[color=brown]You could also preface titles with a marker like "Reprint: ", then use something like this:

Code:
{if title REGEXP "Reprint: "}
   The title contained the text "Reprint: "
{else}
   This is not a reprint...
{/if}

Hope this helps get you started...

Thanks John.

I get the way this stuff works now. I'd rather not adjust the Title, those potentially may show up on other blogs. So I'm going to try the 2nd author approach. I can use external editors like Ecto or MarsEdit to switch between author accounts easily.

Another thought is to actually put the real Author's name in that line, if you can figure that out, that'd be the best.

But now that I have a few articles, some reprints, some original, how can I change the author's attributes? I suppose It would be easy to just delete and republish from the correct account, but do you know a better/smarter way?

Thx again.
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Tue Aug 02, 2005 11:14 am    Post subject: Re: if/then code for article / main page/ category templates Reply with quote

I get the way this stuff works now. I'd rather not adjust the Title, those potentially may show up on other blogs. So I'm going to try the 2nd author approach. I can use external editors like Ecto or MarsEdit to switch between author accounts easily.

There's one catch there... (You knew there had to be one!) I think you need to give full Administrator status to the second poster to be able to use a blogging client like ecto etc. Custom permissions or Trusted Posters are not currently able to post with blogging clients, but they can get the rights via the web interface. Something we'll need to take care of down the road...

But now that I have a few articles, some reprints, some original, how can I change the author's attributes? I suppose It would be easy to just delete and republish from the correct account, but do you know a better/smarter way?

It is not possible to change the author once an article is posted, you would need to delete and repost.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Tue Aug 02, 2005 11:37 am    Post subject: One more thing... Reply with quote

Quote:
Another thought is to actually put the real Author's name in that line, if you can figure that out, that'd be the best.

Is there any sort of "custom variable" I can use to do this?
Code:
Reprinted from the internet. Original by {Author Name Here} {date here}

Thanks again.
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Tue Aug 02, 2005 11:41 am    Post subject: Re: One more thing... Reply with quote

Is there any sort of "custom variable" I can use to do this?

No, there is no way for you to pass in a custom variable.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Wed Aug 03, 2005 9:09 pm    Post subject: Still having trouble with Specifying author name... Reply with quote

Still having some trouble. I'm trying to differentiate posts among two author names. If author A posts, then the attribute and date line is formatted a particular way. If author B posts, the attribute and line is formatted differently. Here's what I'm trying to code:
Code:
<div class="articleAuthor">
{{if author name is "A""}}
   Do Something Here
{{if author name is "B"}}
   Do Something different here
{{/if}}
</div>

Without a syntax reference of some sort, I'm lost. I've tried to do:

Code:
{{if author eq "A"}}

Code:
{{if author is "A"}}

Code:
{{if author_name eq "A"}}

Code:
{{if author.name eq "A"}}

I've also tried the above with and without single quotes, and no quotes, nothing works.

I "get it" that this default template statement

Code:
{{if author}}

...is just asking the system if the author exists, and then perform an action.

What I'm trying to do is see if Author A exists, and if so, do a particular action. If Author A is not there, is Author B? If so, do something different.

Any help is appreciated.
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Wed Aug 03, 2005 10:05 pm    Post subject: Re: Still having trouble with Specifying author name... Reply with quote

The variable is indeed "author" and not author.name or author_name.

If you are trying to test if the author was "Big Dummy" (author represents the display name not the username) you would code as follows:

Code:
{{if author eq "Big Dummy"}}
   The author of this article is Big Dummy.
{elsif author eq "Small Dummy"}}
   The author of this article is Small Dummy.
{{else}}
   The author of this article was neither the Big nor the Small Dummy.
{{/if}}


That should answer your question...


Last edited by john on Fri Apr 07, 2006 1:00 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Wed Aug 03, 2005 10:16 pm    Post subject: Problem Solved! Reply with quote

Problem Solved - posting here for future reference:
Code:
<div class="articleAuthor">
{{if author REGEXP "My Main Display Name"}}
   Do my first request
{{else}}
   Do my second request
{{/if}}
</div>

_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Wed Aug 03, 2005 10:23 pm    Post subject: Re: Problem Solved! Reply with quote

Think of REGEXP as "contains".

So if the author name was "John Keegan" and you tested this way:

Code:
{{if author REGEXP "John"}}
   Would match John Keegan or Joe Johnson
{{/if}}


If you are looking to match an author name that is (EQual to) "My Main Display Name", then use:

Code:
{{if author eq "My Main Display Name"}}
   Would only match "My Main Display Name"...
{{/if}}


In your case, either EQ or REGEXP would probably work, but I just want you to see the difference.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Wed Aug 03, 2005 10:25 pm    Post subject: More Kudos... Reply with quote

More kudos to you. I can almost see the light of day here.
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Sat Aug 06, 2005 12:21 pm    Post subject: Search Template? Reply with quote

My "if it's me write this, if it's not, then write this" code works perfectly on the Main Page, and on a specific category template.

But how do I get it to work on the Search template? Search results so the real author's name, not the "if it's not, then write this"

thx
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Sat Aug 06, 2005 12:37 pm    Post subject: Re: Search Template? Reply with quote

There is no template for search results so it's not possible at this time to customize the look of the search results.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
biggerfish



Joined: 31 Jul 2005
Posts: 23
Location: norwalk, ct

PostPosted: Sat Aug 06, 2005 12:40 pm    Post subject: You're kidding Reply with quote

Thanks for the reply, John.

But really: don't you EVER do ANYTHING besides work and provide support? I mean, we all appreciate it, and you go over and above ...but if you get burned out and run away screaming in the streets someday, we'll all be in a lurch.

Please take a break soon. Please. Very Happy
_________________
rich graham
www.biggerfish.biz
norwalk, ct usa
Back to top
View user's profile Send private message Visit poster's website AIM Address
Search all BlogHarbor support resources.
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    BlogHarbor Community Forum Index -> Beginner's Lounge All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum