Page 1 of 1

(Solved) CGContentUtils Droprownlist

Posted: Wed Feb 17, 2016 10:31 am
by idorroc
I try to get a simple Dropdownselector for galleries in the backend. With CGContentUtils i can get the Dropdownlist. But i get no value in the frontend.

{content_module module='CGContentUtils' block='testdropdown' label='Gallerieauswahl 2' value='RC' name='testdropdown' assign='inhgall2'}

{if !empty($inhgall2)}{Gallery dir=$inhgall2}{else}<h1>{eval var=$inhgall2}*{$inhgall2}</h1>{/if}

I just get the "*"
What can be wrong?

CMSMS 2.1.2
AdminSearch 1.0
CGContentUtils 2.1
CGExtensions 1.51.1
CGSimpleSmarty 2.0.5
CMSContentManager 1.1
CMSMailer 6.2.14
DesignManager 1.1.1
FileManager 1.5.2
FormBuilder 0.8.1.3
Gallery 2.1
JMFilePicker 1.0
LISE 1.1
MenuManager 1.50.2
MicroTiny 2.0.3
ModuleManager 2.0.2
Navigator 1.0.2
News 2.50.4
Search 1.50.2

Re: CGContentUtils Droprownlist

Posted: Wed Feb 17, 2016 2:50 pm
by idorroc
Ok solved. It was this scope thing >:(

Re: CGContentUtils Droprownlist

Posted: Thu Feb 18, 2016 3:47 pm
by PinkElephant
Hi idorroc

I'm currently puzzling over the same task in 2.1.2 so would you mind sharing exactly how you set this up?

(I'm falling at the first hurdle where even the UDT for CGContentUtils 'Dropdown from UDT' doesn't seem to be working...)

Re: CGContentUtils Droprownlist

Posted: Thu Feb 18, 2016 7:18 pm
by PinkElephant
It turns out that I should have paid more attention to the logs -- I was using a test page with 'other issues'.

In case it's of any use elsewhere, this UDT did the trick;

Code: Select all

// UDT: gallery_list
// return array of Gallery directories (can be used with CGContentUtils dropdown)

// DEBUG
// return array("A" => "First entry", "B" => "Second entry", "C" => "Third entry");

$galleryArray = array();

// returns empty array if the module doesn't exist
$mod = cms_utils::get_module('Gallery');
if (! is_null($mod)) {
    $galleries = Gallery_utils::GetGalleries();
    foreach ($galleries as $gallery) {
        // exclude the root gallery (with no filename)
        // to exclude galleries with no (active) images, test for $numimages 
        if ($gallery['filename'] != "") {
            $gallery_dir = $gallery['filepath'] . rtrim($gallery['filename'], '/');
            $galleryArray[$gallery_dir] = $gallery_dir;
       }
    }
}

return $galleryArray;