Page 1 of 1
Advanced Content module drop-down help
Posted: Thu Oct 07, 2010 11:41 am
by RepublicOfDave
Hi,
I’m in need of some help with the Advanced Content module and was hoping you guys could help,
At the moment I have a single line content block set up but I need to find a way to have a drop down menu that will allow the backend user the ability to select a single (from multiple) video file located in a destined file on the server. The video will then be set up to be displayed within an area.
Your help would be most appreciated,
Cheers
David
Re: Advanced Content module drop-down help
Posted: Tue Nov 23, 2010 5:27 pm
by lume
Well Georg Bush answered something similar in the german branch of this forum. He is the author of the advanced content module (and GBFilePicker). My current solution - heavily based on his post - has three parts. (I use it to give the Editor a choice to embed a gallery)
part 1: the statement:
Code: Select all
{AdvancedContent block="Gallery" label="Sidebar Images" block_type="dropdown" allow_none=true items=":::list_dir dir='images/Gallery' filetype='d' :::" values=":::list_files dir='images/Gallery' display='relurl' filetype='d':::" smarty=true}
you should note that
- smarty is true - thus you can execute smarty plugins between the ::: delimiters
- list_files is a plugin - this is part 2 of the solution
part 2: A plugin
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#Author: Ludger Merkens (kontakt@cms-merkens.de)
function smarty_cms_function_list_dir($params, &$smarty)
{
$dir = isset($params['dir']) ? $params['dir'] : '';
$display = isset($params['display']) ? $params['display']: 'filename';
$glue = isset($params['glue']) ? $params['glue']: '|';
$filetype = isset($params['filetype']) ? strtolower($params['filetype']) : 'f';
$output = array();
if($GBFilePicker =& cmsms()->modules['GBFilePicker']['object'])
{
$files =& $GBFilePicker->GetFiles($dir); // dir relative to the uploads dir
foreach($files as $onefile)
{
if (strpos($filetype, 'd')===false && $onefile->is_dir) continue;
if (strpos($filetype, 'f')===false && !$onefile->is_dir) continue;
switch($display)
{
case 'relurl':
$output[] = $onefile->relurl; // this will be the url of the file relative to the uploads dir (e.g.: images/image.jpg)
break;
case 'fullurl':
$output[] = $onefile->fullurl; // this will be the full url to the image (e.g.: yourdomain/uploads/images/image.jpg)
break;
case 'filename':
default:
$output[] = $onefile->basename; // this will be the filename (image.jpg)
break;
}
}
} else return "GBFFilePicker not installed!";
$_output = implode($glue,$output); // this will stick the filenames together separated by given glue (=pipe)
return $_output;
}
// 3148
// 0177 7115502
function smarty_cms_help_function_list_dir() {
?>
<h3>Was macht dieser Tag?</h3>
<p>Dieser Tag listet ein Unterverzeichnis (parameter dir) auf. Dabei ist der Haupteinsatzzweck die Bereitstellung von Auswahldaten für AdvancedContent</p>
<h3>Welche Parameter sind möglich</h3>
<table>
<tr><th>Option</th><th>Parameter</th><th>Beschreibung</th><th>Default</th></tr>
<tr><td></td><td><code>dir</code></td><td> Verzeichnis dessen Inhalt angezeigt werden soll (relativer Pfad zu root_path)</td><td>--</td></tr>
<tr><td><em>(*)</em></td><td><code>glue</code></td><td>Verbinder, bzw. Separator zwischen den Verzeichnispfaden</td><td><code>'|'</code></td></tr>
<tr><td><em>(*)</em></td><td><code>display</code></td><td>Einer der Werte <code>(relurl, fullurl, filename)</code></td><td><code>filename</code></td></tr>
<tr><td><em>(*)</em></td><td><code>filetype</code></td><td>Notieren Sie 'f' für Dateien (files) und 'd' um Verzeichnisse (directories) aufzulisten. 'fd' für beides.</td><td><code>'f'</code></td></tr>
</table>
<h3>Voraussetzungen</h3>
<p>Dieses Plugin setzt voraus, dass das Modul <a href="http://dev.cmsmadesimple.org/projects/gbfilepicker">GBFilePicker</a> (© Georg Busch(nan)) installiert ist.</p>
<?php
}
function smarty_cms_about_function_list_dir() {
?>
<p>Author: Ludger Merkens<kontakt@cms-merkens.de> (© 2010)</p>
<p>dieses Plugin beruht in weiten Teilen auf einem Posting von Georg Busch (nan) im Forum von CMS made simple. Das dort veröffentlichte <code>udt</code> wurde leicht erweitert und in ein Plugin konvertiert.</p>
<p>Version: 1.0</p>
<?php
}
?>
sorry for the german descriptions - but it happens to be my native language.
part 3: You need to have GBFilePicker installed, since the plugin above calls this module to do the file listing.
For the gallery I needed to show the subdirectories only. You probably will need the f'iles only. But the plugin code above should give you enough options to finetune the listing as well as the URL formatting.
Good luck and have fun.
Re: Advanced Content module drop-down help
Posted: Thu Jan 13, 2011 7:38 pm
by naturelab
Hi :- I am trying to implement this solution in :-
CMS Made Simple version 1.9.2, AdvancedContent 0.7.1 and GBFilePicker 1.2.
I am having a few problems.
All I am trying to achieve, is to populate a dropdown selector with a list of sub-directories with the "Gallery" directory.
I have used the 'plugin' from this post and saved as "function.list_files.php' in the plugins directory, but errors include :-
Code: Select all
Fatal error: Cannot redeclare smarty_cms_function_list_dir() (previously declared in /home/xxxx/public_html/lib/content.functions.php(975) : eval()'d code:1) in /home/xxxx/public_html/lib/content.functions.php(975) : eval()'d code on line 1
and also, there is no reference to "list_files" in the plugin.
Can anyone help me out ?
Re: Advanced Content module drop-down help
Posted: Thu Jan 13, 2011 8:05 pm
by lume
OOps sorry, I renamed the plugin to list_dir instead of list_files, but forgot to fix the second call to this plugin. Accordingly, you have to save the plugin als function.list_dir.php in directory cms-root/plugins. The plugin should work with your configuration, as I use it with exactly the same configuration.
good look
Re: Advanced Content module drop-down help
Posted: Thu Jan 13, 2011 8:44 pm
by naturelab
Lume - Thankyou for you quick reply. That worked

Re: Advanced Content module drop-down help
Posted: Thu Jan 20, 2011 10:16 pm
by naturelab
Hi :-
I am trying to go one step further now and have two linked dropdowns.
1) Dropdown One - would select a sub directory with Galleries ( this is working )
2) Dropdown Two - would list the files of the sub directory selected in dropdown One.
I am a bit stuck. Does dropdown One have to pre-populate dropdown Two ? Or am I over - complicating things ? Could it all be done in one go ?
Any help greatly appreciated.
Re: Advanced Content module drop-down help
Posted: Fri Jan 21, 2011 5:09 pm
by hoshy
Interesting idea.
But how do you link these dropdowns?
The dropdowns are crerated by the module, aren't they?
I don't know any way to tell dropdown A to change the values of dropdown B if the value of dropdown A is changed.
Don't think that this is possible with AdvancedContent by default.
Re: Advanced Content module drop-down help
Posted: Fri Jan 21, 2011 5:14 pm
by naturelab
Thanks for looking at this. It was a bit too complicated for me. In the end, I just used a GBFilePicker file browser, so the client can browse all directories / files.