Subject: Dropdown list of static pages in the FCKEditor

Posted on: 24/11/05 12:15am
By: phpsocialclub

In order to make it easier for clients to add links to static pages, I have added a drop down menu to the FCKeditor that lists all the static pages on a site. This requires only one new file and one line change to the FCKeditor.

You need to add a file, called CMSlinks.php to the javascript folder in your public_html folder, with the following content

<?php

/* 

By Andrew Gray andrew@graymerica.com

For Geeklog 1.4 with FCKeditor

###INSTALL

Put this file in the {Path to Geeklog HTML}/javascript/ folder

Add the following line to line 41 of {Path to Geeklog HTML}/fckeditor/editor/dialog/fck_link.html

<script src="/javascript/CMSlinks.php"></script>

*/

include("../lib-common.php") ;

//Probably should respect security
 
$sql =  "SELECT sp_id , sp_title FROM {$_TABLES['staticpage']} WHERE 1" ;

$recordset = DB_query($sql) ; 
$result = DB_fetchArray(DB_query($sql)) ; 

//There is probably a better more GL way to do this

while ($i <= DB_numRows($recordset)) {
   $val = DB_fetchArray($recordset) ; 
  
  $url = COM_buildURL ($_CONF['site_url'] . '/staticpages/index.php?page=' . $val[0]);
  
  $staticPagesDropDown .= 'document.write( '<OPTION value="' . $url . '"> ' . htmlentities($val[1]) . ' </OPTION>' );
  ' ;
     
   $i++ ;
      
   }
   
 

?>
//### function to change FCKeditor text field when the Drop Down is changed
function CMSdrop()
	{
	var newUrl = GetE('cmslink').value ; 
	GetE('txtUrl').value = newUrl ;
	}

//### Write the HTML needed, put here so we do not have to edit much in FCKeditor source	

document.write('<tr><td colspan="3">Internal Link ') ;	
document.write('<select id="cmslink" onChange="CMSdrop();"> ') ; 
<?php echo $staticPagesDropDown ; ?> 

document.write('</select></td></tr>') ; 




you need to add one line to the FCKEditor file after that

Please tell me if there are any problems you see or improvements to make

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=60402