Including standard biographies in articles
4 posts by 3 authors in: Forums > CMS Builder
Last Post: December 1, 2010 (RSS)
By steve_e - November 24, 2010
The authors are regular contributors, and rather than copying their biogs and photos manually into each article, I'd like to set up the article section so that the administrator adding the article can select the biog and photo from a dropdown list.
I assume that I'll need a separate section to enter the biog and photo (which is not a bad thing because it then allows me to show a separate list page of all contributing authors. But I'm not clear on how I can include these two fields from one section into another.
Re: [steve_e] Including standard biographies in articles
By Jason - November 24, 2010
What you can do is create a section called Authors. In that section you can have the author's name, Bio, image, etc.
In your article section, you can have an author drop down that pulls information from the authors table. You can use any field you like for the label, but use num for the value.
Then, in your detail page, after you've selected your article, you can do a second query to retrieve your author record.
In this example, it's assumed that your using a variable called $article to store your article record on the detail page.
list($authorRecord,$authorMetaDate)=getRecords(array(
'tableName' => 'authors',
'allowSearch' => false,
'limit' => 1,
'where' => "num = '".intval($article['author'])."'",
));
if($authorRecord){
$author = $authorRecord[0]; //get first record
}
else{
$author=array();
}
At the end of this code, you have everything from the author table for the author associated with that article stored in $author.
You'll have to do a check to see if an author was returned before outputting information (in case no author is associated with the record).
example:
<?php if($author):?>
** OUTPUT AUTHOR INFORMATION **
<?php endif ?>
Hope this helps get you started. Give this a try and let me know if you run into any problems.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Including standard biographies in articles
By zip222 - November 24, 2010
Re: [Jason] Including standard biographies in articles
By steve_e - December 1, 2010