Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-03-29 14:12:03
- R.M.S.
- Member
- Registered: 2005-09-12
- Posts: 15
Link to the preview of an article.
… Is it possible to easily link to the preview of an article, and if not, any ideas on how it should be hacked?
I’ve tried a simple link to: index.php?event=article&step=edit&view=preview&ID=XX ; My zem_article_info plugin does get/display the ID (in the permlink) and wordcount of the article I’m trying to display, but the preview itself (title and body) does not display.
Offline
Re: Link to the preview of an article.
Someone more knowledgeable than I am could probably offer a technically-oriented discussion on how to make this work. But, as a non-coder, I see this being —difficult— harder to achieve for one reason: full articles have permalinks, but excerpts usually don’t. And unless there’s you find a way around that (e.g., by attaching the excerpts to each corresponding individual article), there’s no way to consistently link to the preview of an article.
That’s my take on it anyway. I wouldn’t be surprised if someone whipped up a cool way to make this work without hacking the source.
Offline
#3 2006-03-29 17:27:36
- R.M.S.
- Member
- Registered: 2005-09-12
- Posts: 15
Re: Link to the preview of an article.
I see no reason why it would be so difficult: it’s possible to link to the edit-screen (just remove the “view” part in the url as given above), so why not the preview screen? It probably has something to do with posted ($_POST) values, but I just can’t find what.
Offline
Re: Link to the preview of an article.
Upon rereading, I think I misunderstood your question, R.M.S. For whatever reason, I thought you meant article excerpts, not the article preview in the backend. My bad—feel free to disregard what I wrote above.
Offline
#5 2006-03-29 19:49:20
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Link to the preview of an article.
Is it possible to easily link to the preview of an article, and if not, any ideas on how it should be hacked? I’ve tried a simple link… but the preview itself (title and body) does not display.
I don’t understand what you’re trying to do. Link from where?
Offline
#6 2006-03-29 21:58:28
- R.M.S.
- Member
- Registered: 2005-09-12
- Posts: 15
Re: Link to the preview of an article.
Mary wrote:
bq. Is it possible to easily link to the preview of an article, and if not, any ideas on how it should be hacked? I’ve tried a simple link… but the preview itself (title and body) does not display.
I don’t understand what you’re trying to do. Link from where?
From anywhere. Just put a link somewhere to a preview of an article. (Not, of course, for front-end users, it is part of the functionality of some custom code I’m writing for my implementation of TxP).
Offline
Re: Link to the preview of an article.
Out of curiosity, why are you trying to link to the article preview instead of, say, the article edit screen?
Offline
#8 2006-03-30 08:45:10
- R.M.S.
- Member
- Registered: 2005-09-12
- Posts: 15
Re: Link to the preview of an article.
It is the part of the front-end of a little version control system I’m coding, and I want to give users the ability to preview other versions of an article, not to edit them. I could of course make my own “preview view”, but I’m trying to use as much standard code as possible.
Offline
#9 2006-03-31 09:42:15
- R.M.S.
- Member
- Registered: 2005-09-12
- Posts: 15
Re: Link to the preview of an article.
onclick=“document.article.view.value=‘preview’;” kind of works, although it makes it impossible to give through any values with your URL (?x=y)
Offline
#10 2006-04-01 19:34:50
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Link to the preview of an article.
It’s not easily possible.
It’s got to do with how the article tab works: when you click preview or any of those tabs, the article doesn’t get saved and re-fetched from the database. Rather, it POSTs the contents of your article back to the write tab, telling it to render what you’ve sent.
Now, you could conceivably make a plugin to fetch this data from the database to construct a link to contain this data, but, there is a limit as to how much data can be sent through the GET method (a link), which is why it is POSTed (sent silently) through the write tab form. So, you could make a plugin to emulate this form, and make it work through a link, by making your form then adding a “link” that submits the form via JavaScript.
Offline
#11 2006-04-03 19:32:00
- R.M.S.
- Member
- Registered: 2005-09-12
- Posts: 15
Re: Link to the preview of an article.
Interesting. Could you refer to any specific lines / files where the preview page is constructed from these POST’ed values?
Offline
#12 2006-04-03 19:49:35
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Link to the preview of an article.
The preview “tab” executes the form (document.article.submit()
), sending the values.
Lines 16-23 define the form values to look for, and line 227 makes them available to the relevant function. Because our $view is, “preview” rather than “text” (246), the preview data is grabbed from the posted form (268-287).
Offline
Pages: 1