Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-04-09 10:16:07
- SebastianS
- Member
- From: Australia
- Registered: 2007-10-05
- Posts: 46
To link "write title" directly to offsite URL..
What I mean by this is:-
Say you have a list of titles in a category, for example CSS-Resources
Ok I want “100+ Resources for Web Developers” to go directly to blog-well
because it is a link to an off site URL
but am happy for “CSS and IE” to go to http://webdevelopmentnotes.com/Web_Development/91/css-and-ie.
How do I do this?
Last edited by SebastianS (2008-04-09 10:18:12)
Offline
Re: To link "write title" directly to offsite URL..
You could for instance establish a per-address-redirect via a line in .htaccess:
Redirect /Web_Development/96/100-resources-for-web-developers http://blog-well.com/2008/03/04/100-resources-for-web-developers/
This would be feasible with a plugin, too. I’m not quite sure if one exists, though.
As a third possibility, add these lines to your article’s body:
<txp:if_individual_article>
<notextile>
<txp:php>
header('Location: http://blog-well.com/2008/03/04/100-resources-for-web-developers/');
</txp:php>
</notextile>
</txp:if_individual_article>
Last edited by wet (2008-04-09 11:56:59)
Offline
#3 2008-04-09 12:41:15
- SebastianS
- Member
- From: Australia
- Registered: 2007-10-05
- Posts: 46
Re: To link "write title" directly to offsite URL..
Thank you for your reply.
I know nothing about .htaccess and just had a look at it and wouldn’t know where to insert the code.
A plugin would be great if it existed.
txp:if_individual_article>
<notextile>
<txp:php>
header('Location: http://blog-well.com/2008/03/04/100-resources-for-web-developers/');
</txp:php>
</notextile>
</txp:if_individual_article>
has it’s merits. I added it to the ‘web development’ page template and everything on the css resources category page became linked to http://blog-well.com/2008/03/04/100-resources-for-web-developers.
Is there some magic form I could use that lI could link specific article id’s to it.
Something like <txp:article id=”#” form=“siteurl” /> the “siteurl’ linking directly to another web address.
So theoretically I just need the code for the form if it exists.
Last edited by SebastianS (2008-04-09 12:42:46)
Offline
Re: To link "write title" directly to offsite URL..
SebastianS wrote:
…I added it to the ‘web development’ page template
So, why didn’t you just add the sequence to the specific article’s body?
Offline
#5 2008-04-09 12:55:39
- SebastianS
- Member
- From: Australia
- Registered: 2007-10-05
- Posts: 46
Re: To link "write title" directly to offsite URL..
Robert said:- “so, why didn’t you just add the sequence to the specific article’s body?”
Well I didn’t realise one could do that, I also didn’t also realise what an articles body is, I know basic terminology.
Thank you very much for helping me with that. It worked.
So simple when you know how. Thank you again, I spent ages trying unsuceesfully to work that out.
Offline
Re: To link "write title" directly to offsite URL..
@wet: Robert, I tried your ‘body’ solution in TXP 4.0.6 to redirect from an old article to an update on the same site. It doesn’t work as expected. No redirect is happening.
- Even the 100% pure code copy redirecting to the external link is not working.
- The code was added at the very top of the article body.
- The rest of the article body remained.
- Deleting everything but the code doesn’t help.
- I am calling the article URL (and not from an article list).
- PHP in articles is allowed and I am in the role ‘publisher’.
Without the <notextile> tag I also got a syntax error. Funny, I thought the space at the beginning of the line would be enough?
What could be wrong in my case?
Edit: Well, reading some documentation about php header location tells me that the ‘header’ request/output must be the very 1st output from a page. Using it in the article body literally after already hundreds of outputs were sent seems to be not working.
Last edited by merz1 (2008-04-12 12:39:53)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: To link "write title" directly to offsite URL..
Maybe I don’t understand what you’re trying to accomplish, but why not create a custom field called “article_url” and when an article is from an external site, enter the url there. Then in your article form create a conditional that says, “if there is a value in the custom field ‘article_url’ output the title this way (ie with the title linked to the url in that custom field), if not, output the title another way (ie with a normal, site-internal permalink)?
Offline
Re: To link "write title" directly to offsite URL..
nabrown78 wrote:
Maybe I don’t understand what you’re trying to accomplish, but why not create a custom field called “article_url” and when an article is from an external site, enter the url there. Then in your article form create a conditional that says, “if there is a value in the custom field ‘article_url’ output the title this way (ie with the title linked to the url in that custom field), if not, output the title another way (ie with a normal, site-internal permalink)?
Yep, good point Nora. In this case, in example:
<a href="<txp:if_custom_field name="URL"><txp:custom_field name="URL" /><txp:else /><txp:permlink /></txp:if_custom_field>"><txp:title /></a>
Last edited by Gocom (2008-04-11 03:26:00)
Offline
#9 2008-04-11 11:11:43
- SebastianS
- Member
- From: Australia
- Registered: 2007-10-05
- Posts: 46
Re: To link "write title" directly to offsite URL..
Using the code @wet: Robert gave:-
txp:if_individual_article>
<notextile>
<txp:php>
header('Location: http://forum.textpattern.com/viewtopic.php?id=26843');
</txp:php>
</notextile>
</txp:if_individual_article>
I am able to link directly out of my site clicking the title of an article To link write title directly to offsite URL without opening a secondary page on my site
Reading Nora’s post and Jukka’s post it occured to me it should be possible to make a custom field, replacing the forum URl “http://forum.textpattern.com/viewtopic.php?id=26843” in the above code Robert suggested.
Is that possible?
How? What is the code would needed to replace the individual URL to a custom field/conditional tag say called “article_url”.
Last edited by SebastianS (2008-04-11 11:23:35)
Offline
Re: To link "write title" directly to offsite URL..
SebastianS wrote:
How? What is the code would needed to replace the individual URL to a custom field/conditional tag say called “article_url”.
Ya k’nw Sebastian, it’s quit’ eaz’. First example:
<a href="<txp:if_custom_field name="article_url"><txp:custom_field name="article_url" /><txp:else /><txp:permlink /></txp:if_custom_field>"><txp:title /></a>
Or if ya real’ need th’z redirectin’ headers, then:
<txp:if_individual_article>
<txp:if_custom_field name="article_url">
<txp:php>
header('Location: '.custom_field(array(name => 'article_url')));
</txp:php>
</txp:if_custom_field>
</txp:if_individual_article>
Th’z both codes go to ur article form.
Last edited by Gocom (2008-04-11 13:03:13)
Offline
#11 2008-04-12 09:28:07
- SebastianS
- Member
- From: Australia
- Registered: 2007-10-05
- Posts: 46
Re: To link "write title" directly to offsite URL..
Thank you Jukka, success, it took me a little while to realise I had to put the ‘<txp:output_form form=“article_url” />’ tag in the article body. Thank you all for your help.
Offline
Offline
Re: To link "write title" directly to offsite URL..
What I am wondering is if the header (re-) location trick really works inside an article body after several output was sent to the client. PHP docu (search) tells me that even a space before the call provokes an error.
<html>
<?php
/* error provocation because of earlier output */
header('Location: http://www.example.com/');
?>
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: To link "write title" directly to offsite URL..
Textpattern uses output buffering, so it sends browser output at the very end of the whole script. Thus, header() can be used even if some output occured previously, as stated in the PHP manual notes:
Note: As of PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.
Offline
Re: To link "write title" directly to offsite URL..
wet: Still wondering then why your exactly copied header location code doesn’t work inside my articles.
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline