|
|
Due to the volume of spam happening on our forums, posting is now restricted to verified members only. If you're not verified, drop us a note with your username.
|
|
Home > FlexCMS Support Forum > User Help > General Support Requests > Custom Blocks and news
FlexCMS Support Forum
Custom Blocks and news Started January 16, 2006 @ 9:27pm by egam
|
Post Message |
|
|
Custom Blocks and news | January 16, 2006 @ 9:27pm | Hi all,
I'm wondering if I could put the news code in a custom block and if so what is the "trick" to do so cause when I put this line {FlexCMS-Articles|2|0,5|} in a PAGE it work's ok, but when I put it in a custom block and check the PHP box I have an error and when I don't it simply print {FlexCMS-Articles|2|0,5|} on the block.
thanks for your help |
|
|
|
|
|
|
| |
DCSun Administrator
Posts: 625 |
|
|
| January 16, 2006 @ 10:25pm | Hi Egam,
Unfortunately, the blocks do not process code the same way pages do, and therefore the articles code will not work in a block. There's really no trick to using that code in a page, it's just processed by FlexCMS whenever found in a page (but not blocks).
That said, it shouldn't be too complicated to get your news or articles displayed in a block. If you would like to try it on your own, you can run a MySQL query that reads from the na-Articles table. Or, if you let us know what you're looking for it to do we can probably give you a bit of custom code to accomplish it.
David
FlexCMS v3.2 Has Been Released! |
|
|
|
|
|
|
| |
|
|
| January 17, 2006 @ 1:59pm | Thanks for the answer David,
Here's what I'm trying to do, it's really put the news in a block and not in a page cause I'm developing a site that not only me would put updates and modify page but the other don't know anything about coding, so it could be really easy for that person to earase the news section on the pages, but it would also be more easy to have the news ont all pages of the site than putting it in all created pages.
thanks agains.
|
|
|
|
Last Edit: January 17, 2006 @ 2:02pm by egam | |
|
|
|
| |
DCSun Administrator
Posts: 625 |
|
|
| January 18, 2006 @ 11:13pm | Egam,
Try this code and see if it produces something like what you're looking for. Just paste it into a block and enable PHP on it. The $ArticlesCount and $Categories at the top work the same as those sections in the articles code that goes in pages.
If you're going to start messing around with the code (the MySQL portions especially), you may wish to do so in a page and then move it to a block when you're done with it. If you experiment on a live block you may find yourself needing to modify it from the database to get it working again.
David
Code
$ArticlesCount = '5'; $Categories = '0';
$TeaserLength = 100;
// ========================
$ArticlesCode = ''; $ArticlesPrinted = 0;
if (strpos($ArticlesCount,',') !== false) { list($ACOffset,$ACCount) = explode(',',$ArticlesCount); $LimitString = intval($ACOffset).','.intval($ACCount); } else { $LimitString = intval($ArticlesCount); } if ($CategoriesList != '') { $CategoriesArray = explode(',',$CategoriesList); for ($i = 0; $i < count($CategoriesArray); $i++) { $CategoriesArray[$i] = intval($CategoriesArray[$i]); } $CategoriesList2 = implode(',',$CategoriesArray); $query_na = "SELECT * FROM `".$Settings['DBPrefix']."na-Articles` WHERE ApprovedBy!='' AND Category IN (".$CategoriesList2.") ORDER BY DateCode DESC LIMIT ".$LimitString; } else { $query_na = "SELECT * FROM `".$Settings['DBPrefix']."na-Articles` WHERE ApprovedBy!='' ORDER BY DateCode DESC LIMIT ".$LimitString; }
$result_na = mysql_query($query_na) or die (mysql_error()); while ($row_na = mysql_fetch_array($result_na)) { if ($row_na['Teaser'] == '') { $StrippedArticle = strip_tags($row_na['Article']); if (strlen($StrippedArticle) > $TeaserLength) { $TeaserSection = substr($StrippedArticle,0,$TeaserLength); while (substr($TeaserSection,strlen($TeaserSection)-1,1) != ' ') { $TeaserSection = substr($TeaserSection,0,strlen($TeaserSection)-1); } while (substr($TeaserSection,strlen($TeaserSection)-1,1) == ' ') { $TeaserSection = substr($TeaserSection,0,strlen($TeaserSection)-1); } $TeaserSection .= '... <font size="1">[<a href="'.$MainURL.'/articles/view/'.$row_na['RecordNumber'].'.html">'.$MsgText[7][78].'</a>]</font>'; $row_na['Title'] = '<a href="'.$MainURL.'/articles/view/'.$row_na['RecordNumber'].'.html">'.$row_na['Title'].'</a>'; $ArticleLinked = 'y'; } else { $TeaserSection = $StrippedArticle; } } else { $TeaserSection = substr($row_na['Teaser'],0,$TeaserLength); if (strlen($row_na['Teaser']) > strlen($TeaserSection)) { while (substr($TeaserSection,strlen($TeaserSection)-1,1) != ' ') { $TeaserSection = substr($TeaserSection,0,strlen($TeaserSection)-1); } while (substr($TeaserSection,strlen($TeaserSection)-1,1) == ' ') { $TeaserSection = substr($TeaserSection,0,strlen($TeaserSection)-1); } } $TeaserSection .= '... <font size="1">[<a href="'.$MainURL.'/articles/view/'.$row_na['RecordNumber'].'.html">'.$MsgText[7][78].'</a>]</font>'; $row_na['Title'] = '<a href="'.$MainURL.'/articles/view/'.$row_na['RecordNumber'].'.html">'.$row_na['Title'].'</a>'; $ArticleLinked = 'y'; }
$ArticlesPrinted++; if ($ArticlesCode != '') { $ArticlesCode .= '<br><br>'; } $ArticlesCode .= '<b>'.$row_na['Title'].'</b><br>'.$TeaserSection;
} // end while rows loop print $ArticlesCode; |
|
|
FlexCMS v3.2 Has Been Released! |
|
|
|
|
|
|
| |
|
|
| January 19, 2006 @ 6:49pm | Thaks a lot David.
That does exacly what I wanted it to do! and you've juste saved me a headack.
thanks a gain for you help.
|
|
|
|
|
|
|
| |
DCSun Administrator
Posts: 625 |
|
|
| January 19, 2006 @ 9:52pm | Not a problem! I'm glad that accomplished what you were after.
David
FlexCMS v3.2 Has Been Released! |
|
|
|
|
|
|
|
|
|
| MEMBERS
|
|
|