Advanced Content

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Advanced Content

Post by MantaPro »

Is it possible in a smarty template to generate output from a module's public functions? - Or via a UDT ?

Examples of the smarty templates where this may be attractive:
  • a Core::Generic template in Design Manager that could be included in to a content page or a Core::Page template;
  • The smarty template for Option/Value pairs in the dropdown field in CGContent Utilities
  • Etc
And the kinds of public functions I hope are accessible:
  • A list of all of the entries in CGSharedContent - via the block_query class
  • A list of categories in the LinkMgr - could do this by sorting an array from the output of a LinkMgr template
  • List of Map Names (& IDs) from CGGoogleMaps2
  • List of forms from CGBetterForms
I haven't browsed the code of the example modules mentioned above yet to see ; if it can't be done via Smarty or a UDT then its academic - thanks in advance

Using CMSMS 2.2.9.1 and latest versions of all modules mentioned above

Pointers on how or links to examples much appreciated

Thanks in advance
deactivated010521

Re: Advanced Content

Post by deactivated010521 »

CGContentUtils has a few options to manage content blocks of various types.

Perhaps you find this module useful otherwise get some inspiration to program something yourself.

What I like about CGContentUtils is that you can also specify user groups to allow/disallow access.
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Re: Advanced Content

Post by MantaPro »

Thanks arnoud for the reply

Yes I am already making use of CGContentUtilities - in fact as I describe in my original question - I was hoping to get the output I am seeking in to the smarty template for the Dropdown field provided by CGContentUtilities

My question was I hoping for some assistance to make use of public methods within various modules (that are not part of the normal API declared to smarty)

eg. to do something like this via a UDT

Code: Select all

if ($cgsc = cmsms()->GetModuleInstance('CGSharedContent'))
{     

      $b = $cgsc->block_query(array('limit'=>50,'offset'=>0));
      $smarty->assign('blocks']), $b);
}
And either process $b in the UDT to create an array of Option=Value pairs or do it to {$blocks} within the template

I'll continue to experiment and dust off my flakey OO PHP
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Re: Advanced Content

Post by MantaPro »

Not ideal (I'll dust off my OO sometime LOL) but for now this works:

UDT called CGSharedBlocks

Code: Select all

$gCms = cmsms();
$db = $gCms->getDb();
$db_prefix = "cms2_";
$query = "  SELECT name FROM ".$db_prefix."mod_cgsc_blocks;";
$dbresult =$db->Execute($query);
while($dbresult && $row = $dbresult->FetchRow()) {
  $block[] = $row['name'];
};
$smarty->assign('sc_blocks', $block);
And in CGContentUtilities, create a block called "SharedContentPicker", Type: Dropdown and in the Template

Code: Select all

{CGSharedBlocks}
{foreach from=$sc_blocks item='block' name='loop'}
  {$loop@iteration}|{$block}
{/foreach}
Then towards the top of one of your Core::Page templates

Code: Select all

   {$scb="{content_module module='CGContentUtils' block='SharedBlockPicker' priority=10}" scope="global"}
Then at the appropriate place in the template where you want the selected Shared Content Blocks to display

Code: Select all

{if isset($scb) && $scb}
   {CGSharedContent name="$scb"} 
{/if}
Not ideal but it works - I'll change the Block type to Multiselect then at the bottom of the page template loop through the array to output as many shared content blocks as are selected
Post Reply

Return to “Modules/Add-Ons”