How to create "Related Links"

5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 12, 2011   (RSS)

Re: [jacgo] How to create "Related Links"

By gkornbluth - May 12, 2011

jaccgo,

I'm not sure exactly what you're asking.

Do you want to create the expanding menus on the left side?

If so, I've used anylink and other scripts from Dynamic Drive http://www.dynamicdrive.com/dynamicindex1/index.html on some of my sites.

You can then pull the link data from your database using a number of approaches to suite your needs.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] How to create "Related Links"

By jacgo - May 12, 2011

Thanks so much for your help.

but my mean is I want to create the related link page on CMSbuilder.
share other site link for visitor.

"http://cmnst-en.ncku.edu.tw/files/11-1045-5665.php"

Hope you can understand it..

Thank you again!

Re: [jacgo] How to create "Related Links"

By gkornbluth - May 12, 2011

Hi jacgo,

Sorry that was not what you wanted.

If you mean "how to create the list of links that appears under NANO lnks", then you’d create a multi-record editor with at least 2 text fields. One for the "link_text", and another for the link "URL". You could even include a text box field for a description of the link as I did in the example below, or even include an image upload field for a thumbnail appropriate for that link. Besides the link text and actual link fields, the rest depends on your client’s needs.

As and example, here’s the code I use on the CMSB Cookbook Resources page. thecmsbcookbook.com/resources.php

I set up a multi-record viewer called “resources” with text fields for “title”, “URL”, and “link_text” as well as a text box field for “content”

In the head are the standard load and get records calls for the “resources” table. (You’ll have to change the dirsToCheck code to match the path to your viewer)
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/hsphere/local/home/gkornblu/thecmsbcookbook.com/','','../','../../','../../../');
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($resourcesRecords, $resourcesMetaData) = getRecords(array(
'tableName' => 'resources',
));

?>



And in the body where you want the list of links to appear:
<table width="800" border="0" cellpadding="0">
<tr>
<td align="left">
<?php
if (!preg_match("/^http:\/\//i", $record['url'])) {
$record['url'] = "http://" . $record['url']; }
?>
<?php $title = htmlspecialchars($record['title']); ?> <b><?php echo strtoupper($title); ?></b><br /><br /><?php echo $record['content'] ?> - <a href="
<?php echo $record['url'] ?>" target="_blank"><?php echo $record['link_text'] ?></a><hr align="center" color="#999999" /></td>
</tr>
<?php endforeach; ?>
</table>


The strtoupper code forces the "title" to appear in capital letters. The preg_match code is optional but insures that your links work and display correctly by adding an http:// to the beginning of the URL if you forget to add one.

There’s a lot more on these and related topics in the CMSB Cookbook http://www.thecmsbcookbook.com

Hope that’s what you were looking for.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] How to create "Related Links"

By jacgo - May 12, 2011

Thank you very much for the help!