Sub articles. Is it possibile?
4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 14, 2011 (RSS)
By mbareara - March 8, 2011
Hi :-)
i'm building my news site starting from am2.
I really appreciate new features of CmsBuilder. It is .... WOW!!!
But i have a problem:
I want to put, in listviewer, and behind each article two or three related articles choosen by author from article list.
I'vre created a field in 'article' table called 'related_article' as list. Label= article Values= num.
Now in the listviewer i would have
ARTICLE 1
><a href="related article title link">related article title</a>
ARTICLE 2
><a href="related article title link">related article title</a>
I know it is impossibile with left join because related article are in the same table...
Any suggestion?
Thank you in advance :-)
Orazio
i'm building my news site starting from am2.
I really appreciate new features of CmsBuilder. It is .... WOW!!!
But i have a problem:
I want to put, in listviewer, and behind each article two or three related articles choosen by author from article list.
I'vre created a field in 'article' table called 'related_article' as list. Label= article Values= num.
Now in the listviewer i would have
ARTICLE 1
><a href="related article title link">related article title</a>
ARTICLE 2
><a href="related article title link">related article title</a>
I know it is impossibile with left join because related article are in the same table...
Any suggestion?
Thank you in advance :-)
Orazio
Re: [orazio] Sub articles. Is it possibile?
By Jason - March 8, 2011
Hi Orazio,
I'm assuming related_article field is a multi-value list. Is that right?
Multi-value fields store values as a string separated by tab characters (\t). We for each record, we can get this list and then use it to do another query to the database to get related articles. Try something like this:
You can use this for each article you're outputting to get related articles.
Hope this helps get you started.
I'm assuming related_article field is a multi-value list. Is that right?
Multi-value fields store values as a string separated by tab characters (\t). We for each record, we can get this list and then use it to do another query to the database to get related articles. Try something like this:
<?php
$relatedArticleNums = join( ",", explode( "\t", trim( $record['related_articles'], "\t" ) ) );
if(!$relatedArticleNums){ $relatedArticleNums = "0"; }
list( $relatedArticles, $realtedArticlesMetaData ) = getRecords( array(
'tableName' => 'articles',
'allowSearch' => false,
'where' => "num IN ($relatedArticleNums)",
) );
?>
You can use this for each article you're outputting to get related articles.
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
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] Sub articles. Is it possibile?
By mbareara - March 12, 2011
Sorry but i don't understand...
I made this
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/siciliatoday/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load records
list($articoliRecords, $articoliMetaData) = getRecords(array(
'tableName' => 'articoli',
'leftJoin' => array(
'category' => 'categoria',
),
));
$relatedArticleNums = join( ",", explode( "\t", trim( $record['articoli_correlati_1'], "\t" ) ) );
if(!$relatedArticleNums){ $relatedArticleNums = "0"; }
list( $relatedArticles, $relatedArticlesMetaData ) = getRecords( array(
'tableName' => 'articoli',
'allowSearch' => false,
'where' => "num IN ($relatedArticleNums)",
) );
?>
But it gives me an erorr server...
I made this
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/siciliatoday/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load records
list($articoliRecords, $articoliMetaData) = getRecords(array(
'tableName' => 'articoli',
'leftJoin' => array(
'category' => 'categoria',
),
));
$relatedArticleNums = join( ",", explode( "\t", trim( $record['articoli_correlati_1'], "\t" ) ) );
if(!$relatedArticleNums){ $relatedArticleNums = "0"; }
list( $relatedArticles, $relatedArticlesMetaData ) = getRecords( array(
'tableName' => 'articoli',
'allowSearch' => false,
'where' => "num IN ($relatedArticleNums)",
) );
?>
But it gives me an erorr server...
Re: [orazio] Sub articles. Is it possibile?
By Jason - March 14, 2011
Hi,
You need to do the query that selects the related articles while you're outputting your first set of articles.
If you could attach the .php file you're working with, I can help give you a better example.
Thanks
You need to do the query that selects the related articles while you're outputting your first set of articles.
If you could attach the .php file you're working with, I can help give you a better example.
Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/