Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[php/plugin] get article attributes without outputting article
I am trying to create a custom article list through a specialized plug or block of php code. On a page, there will be two randomized article lists in different columns. The each list will have a specified number of articles (between 3-5). The top article in the list will have to have an image (and will display the thumbnail of that article image), and the rest will just display text excerpts.
I am encountering one (of probably several) problems constructing the code.
I am tring to create a function that will get a number of random arcticles that are not currently displayed on the page. I am tring to assign a list of article IDs to the array $visible_articles. I know you can use $thisarticle[‘id] to get the id of an article just outputted. Is there a way of getting the ID of an article called from the article_custom($atts) function without printing the actual article? I am thinking of something along the lines of:
<code>
function find_random_article() {
$article = article_custom($atts…);
if article ID is not in array of $visible_articles {
then print $article and add article ID to array of visible article id’s;
else find_random_article();
}
}
</code>
The problem is getting article ID without printing it… Any thoughts? I have scored through publish.php but to no avail. Jeff.
Last edited by Jeff_K (2006-02-21 00:58:43)
Offline
#2 2006-02-21 01:59:54
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: [php/plugin] get article attributes without outputting article
Just use article_custom, and a form that doesn’t include any tags that output the article.
Sure you’re not overcomplicating things? Displaying random article(s), and using a special layout for the first article in a list, are in the FAQ.
Alex
Offline
Re: [php/plugin] get article attributes without outputting article
Thanks Alex, that did the trick. The reason I needed to create the plugin is because 1) all of the articles in a given category don’t have images, so I needed a way of looping through until one with an image is found, and 2) I needed to divide the list into two columns (both with thumbs at the top), and needed a way of remember whats already been outputted on the page.
Here is the <a href=“http://fillip.ca”>result</a>. The overall page still needs some work, but the plugin seems to be working well so far..
Offline