, Guest!
Already a Member? Login or Register.

Menu



Showcase


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 > Code Snippets > Code Snippets: FlexCMS 3.2.1

FlexCMS Support Forum


Code Snippets: FlexCMS 3.2.1
Started May 11, 2010 @ 11:08pm by otter
Post Message 
otter
Administrator



Posts: 177
 
Code Snippets: FlexCMS 3.2.1May 11, 2010 @ 11:08pm
The following five code snippets were included in the FlexCMS 3.2.1 FULL release. If you'd like to add these to your site, you can do so by copying and pasting from the code below.


#1 Index/List of News/Article Categories

ID/Name: ArticlesCategoryIndex

Type: PHP

CODE:

Code

$query_na = "SELECT * FROM `".$Settings['DBPrefix']."na-Categories` WHERE Parent='0' ORDER BY CategoryName asc";

$result_na = mysql_query($query_na) or die (mysql_error());
while ($row_na = mysql_fetch_array($result_na)) {

print '<a
href="'.$MainURL.'/articles/'.$row_na['RecordNumber'].'.html">'.$row_na['CategoryName'].'</a><br>';

}



#2 Index/List of eStore Categories

ID/Name: eStoreCategoryIndex

Type: PHP


Code

if ($Arguments1 == 'store') {

print '<font size="1">';

$query100 = "select * from `".$Settings['DBPrefix']."ec-Categories` where Parent='0' order by Name asc";
$result100 = mysql_query($query100) or die (mysql_error());
while ($row100 = mysql_fetch_array($result100)) {

print '<a href="'.$MainURL.'/store/browse/'.$row100['CategoryID'].'.html" class="BlockColors">'.$row100['Name'].'</a><br><img src="'.$ImagesURL.'/spacer.gif" width="1" height="5" alt="" border="0"><br>';

}



#3 Random Photo from the Galleries

ID/Name: RandomPhoto

Type: PHP


Code

$query = "select * from `".$Settings['DBPrefix']."pg-Settings`";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$pgSettings[$row['Name']] = $row['Value'];
}

if ($pgSettings['StorageLocationHTTP'] == '') {
$pgSettings['StorageLocationHTTP'] = $BaseURL.'/pg_images';
}
if ($pgSettings['StorageLocationLocal'] == '') {
$pgSettings['StorageLocationLocal'] = './pg_images';
}

$Extensions[2] = '.jpg';
$Extensions[3] = '.png';

$ThumbExtensions[2] = '-thumb.jpg';
$ThumbExtensions[3] = '-thumb.png';

if (substr($pgSettings['StorageLocationHTTP'],0,1) == '/') {
$ImageBaseHTTP = $BaseURL.$pgSettings['StorageLocationHTTP'];
}
else {
$ImageBaseHTTP = $pgSettings['StorageLocationHTTP'];
}



$query = "select * from `".$Settings['DBPrefix']."pg-Images` ORDER BY RAND() limit 1";
$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_array($result);


// figure out thumbnail dimensions
$NewWidth = $pgSettings['ThumbMaxWidth'];
$NewHeight = $pgSettings['ThumbMaxHeight'];

$WidthRatio = $row['ImageWidth'] / $NewWidth;
$HeightRatio = $row['ImageHeight'] / $NewHeight;

if ($WidthRatio >= $HeightRatio) {
$NewWidthCalc = number_format($row['ImageWidth'] / $WidthRatio, 0);
$NewHeightCalc = number_format($row['ImageHeight'] / $WidthRatio, 0);
}
else {
$NewWidthCalc = number_format($row['ImageWidth'] / $HeightRatio, 0);
$NewHeightCalc = number_format($row['ImageHeight'] / $HeightRatio, 0);
}

$ImageWidth = $NewWidthCalc;
$ImageHeight = $NewHeightCalc;


$query2 = "select * from `".$Settings['DBPrefix']."pg-Galleries` where RecordNumber='".$row['GalleryNumber']."' limit 1";
$result2 = mysql_query($query2) or die (mysql_error());
$row2 = mysql_fetch_array($result2);

print '<a href="'.$MainURL.'/photos/'.$row2['RecordNumber'].'.html" class="BlockColors"><img src="'.$ImageBaseHTTP.'/'.$row['FileName'].$ThumbExtensions[$row['FileType']].'" width="'.$ImageWidth.'" height="'.$ImageHeight.'" border="0" alt=""><br>'.$row2['GalleryTitle'].'</a>';




#4 List of Calendar Events for Today’s Date

ID/Name: TodaysEvents

Type: PHP


Code

$TZO = (($Settings['TimezoneOffset']+5)*3600);


$DateSplit = getdate();
$DayTimestamp = mktime(0,0,0,$DateSplit['mon'],$DateSplit['mday'],$DateSplit['year']);


$query55 = "select * from `".$Settings['DBPrefix']."cl-EventDates` where DateCode>=".($DayTimestamp+$TZO)." and DateCode<".($DayTimestamp+86400+$TZO)." order by DateCode asc";
$result55 = mysql_query($query55) or die (mysql_error());
if (mysql_num_rows($result55) > 0) {

while ($row55 = mysql_fetch_array($result55)) {

$query5 = "select * from `".$Settings['DBPrefix']."cl-Events` where RecordNumber='".$row55['EventID']."' and MinLevel<='".$UserLevel."' limit 1";
$result5 = mysql_query($query5) or die (mysql_error());
if (mysql_num_rows($result5) > 0) {
$row5 = mysql_fetch_array($result5);

print '<img src="'.$ImagesURL.'/spacer.gif" width="1" height="5" alt="" border="0"><br>';


print '<a href="'.$MainURL.'/calendar/details/'.$row5['RecordNumber'].'.html">'.$row5['Title'].'</a>';


if ($row5['StartTime'] >= 0) {

$Hours = 0;
$Minutes = 0;

$Seconds = $row5['StartTime'];
while ($Seconds >= 3600) {
$Seconds = $Seconds - 3600;
$Hours++;
}
while ($Seconds >= 60) {
$Seconds = $Seconds - 60;
$Minutes++;
}


$Suffix = 'am';
if ($Hours >= 12) {
$Hours -= 12;
$Suffix = 'pm';
}
if ($Hours == 0) {
$Hours = 12;
}

if ($Minutes < 10) {
$Minutes = '0' . $Minutes;
}

$TimePrint = $Hours . ':' . $Minutes . $Suffix;

//if ($row55['EndTime'] >= 0 && $row55['EndTime'] > $row55['StartTime']) {
if ($row5['EndTime'] >= 0) {

$Hours = 0;
$Minutes = 0;

$Seconds = $row5['EndTime'];
while ($Seconds >= 3600) {
$Seconds = $Seconds - 3600;
$Hours++;
}
while ($Seconds >= 60) {
$Seconds = $Seconds - 60;
$Minutes++;
}


$Suffix = 'am';
if ($Hours >= 12) {
$Hours -= 12;
$Suffix = 'pm';
}
if ($Hours == 0) {
$Hours = 12;
}

if ($Minutes < 10) {
$Minutes = '0' . $Minutes;
}

$TimePrint .= ' - ' . $Hours . ':' . $Minutes . $Suffix;

}

}
else {
$TimePrint = '';
}


if ($TimePrint != '') {
print ' <font size="1">('.$TimePrint.')<br></font>';
}
else {
print '<br>';
}


print '<img src="'.$ImagesURL.'/spacer.gif" width="1" height="5" alt="" border="0"><br>';


$EventsPrinted++;

}

}

}

if ($EventsPrinted < 1) {

print '<br>[No Events Today]<br>?';

}




#5 Total Members & Newest Member

ID/Name: TotalMbrsNewestMbr

Type: PHP


Code

$query = "select count(RecordNumber) as UsersCount from `core-Users`";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
print 'Members: '.$row['UsersCount'];

$query = "select * from `core-Users` order by RecordNumber desc limit 1";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
print '<br><br>Newest Member: <a href="'.$MainURL.'/profile/'.$row['Username'].'.html" class="BlockColors">'.$row['Username'].'</a>';




ONLINE TRAINING CLASSES FOR FLEXCMS IN MAY: FlexCMS Basics (101), Sat., May, 15, 2010 & FlexCMS Blocks (Mon., May 10, 2010).
 

Post Message 




Try & Buy FeedForAll - Easy to use RSS Feed Creator - great for iTunes users!

MEMBERS




All Contents, Code, Scripts and Technologies Copyright 2003-2009 FlexCMS.
All Rights Reserved. Software License Agreement

Processing Time: 0.07276 seconds.
 
Management Login

Powered By FlexCMS
Powered By FlexCMS