Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-07-19 23:32:17

plummerm
Archived Plugin Author
Registered: 2006-06-19
Posts: 22

article_custom inside other functions

Update
Never mind, I figured it out. I just shouldn’t have had the “id” in the article_custom attributes.

Hi,
I think this is the best place to post my question, if not, please let me know.
I’m working on a plug-in for sub-sections (just saw that that feature is already slated for the next release, doh!).

Everything is working fine, but I’m working on a specialized tag that generates a randomized article for a given section. I’m trying to display a random article if any exist in a given section, and if not, display an article from its parent section. If there are no articles in a parent section, it will display a random article from that parent’s parent, etc., etc.

My problem (i think) is unrelated to my subsection scheme- I can get my own functions to work recursively inside the function and output the info from the correct parent.

However, when I call “article_custom” it won’t return any info, even if I fix all the information (instead of using my section variable). I can’t figure out how to make it work in this context.

Maybe this is outside of what this forum is for, but if you have any thoughts I’d love to hear them.

thanks,
Matt

<pre>
function mtp_article_rotate($atts,$section=’‘){ global $pretext; extract($pretext); if(!$section)$section=$s;

$theAtts = lAtts( array( ‘category’ => ‘’, ),$atts); extract($theAtts);

$q = “select ID from `”.PFX.“textpattern` where (`Category1` = ‘$category’ || `Category2` = ‘$category’) AND `Section` = ‘$section’ limit 1”;

if ($r = safe_query($q)) { $thing = (mysql_num_rows($r) > 0) ? mysql_result($r,0) : ‘’; mysql_free_result($r); } if(!$thing){ return mtp_article_rotate($atts,mtp_section_parent($section)); }else{ //any output of just the section variable works fine here, but not article_custom return article_custom( array( ‘section’=>$section, ‘category’=>‘sidebar’, ‘form’=>‘Sidebar’, ‘sortby’=>‘rand()’, ‘id’=>1, ‘limit’=>1 ) ); }

}
function mtp_section_parent($section) { global $pretext; extract($pretext);

$p = safe_column(“parent”, “mtp_section”, “name=’”.doSlash($section).”’”); return array_pop($p);
}
</pre>

Last edited by plummerm (2006-07-20 15:39:27)

Offline

Board footer

Powered by FluxBB