directory listing like content image tag

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
haapati
Forum Members
Forum Members
Posts: 20
Joined: Sun Sep 10, 2006 4:14 pm

directory listing like content image tag

Post by haapati »

Is there way to get a dropdown menu in content editing where you could choose a specific directory and it would return the directory path in the page template?

Just like the content image tag but instead of picture files it shows just a directory list.

I think I would get the dropdown menu like that if I would edit the code of Content.inc.php. But is there any way to do that without editing the CMSMS Core files?
NaN

Re: directory listing like content image tag

Post by NaN »

I just posted here a possible solution to select multiple images using AdvancedContent and GBFilePicker and a UDT.
This can also be used to list directories only.

Code: Select all


$dir = '';
if(isset($params['dir']))
{
	$dir = $params['dir'];
}
$display = 'filename';
if(isset($params['display']))
{
	$display = $params['display'];
}
$output = array();
if($GBFilePicker =& cmsms()->modules['GBFilePicker']['object'])
{
	$files =& $GBFilePicker->GetFiles($dir); // dir relative to the uploads dir
	foreach($files as $onefile)
	{
		if(!onefile->is_dir) continue;

		switch($display)
		{
			case 'relurl':
				$output[] = $onefile->relurl; // this will be the url of the dir relative to the uploads dir (e.g.: images/)
				break;
			case 'fullurl':
				$output[] = $onefile->fullurl; // this will be the full url to the directory (e.g.: yourdomain/uploads/images/)
				break;
			case 'filename':
			default:
				$output[] = $onefile->basename; // this will be the dirname only (e.g.: images)
				break;
		}
	}
}
$_output = implode("|",$output); // this will stick the dirnames together separated by a pipe
echo $_output;

with AdvancedContent you now can create a dropdown or a multi select list in your template to be used in backend:

Code: Select all


{content block="dirs" label="Select a directory" block_type="dropdown" items=":::list_dirs:::" values=":::list_dirs display='relurl':::" smarty=true}

This should print out a dropdown with dirs only.
Last edited by NaN on Wed Oct 13, 2010 10:32 pm, edited 1 time in total.
Post Reply

Return to “CMSMS Core”