• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Advanced Content
PostPosted: Fri Feb 15, 2019 3:29 am 
Offline
Forum Members
Forum Members

Joined: Sun Feb 03, 2008 8:14 pm
Posts: 52
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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Advanced Content
PostPosted: Fri Feb 15, 2019 2:38 pm 
Offline
Power Poster
Power Poster

Joined: Sun Apr 19, 2009 9:33 am
Posts: 1308
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.

_________________
The CMSMS Builder is a tool to help you develop and optimize CMS Made Simple >= 2.2.3 themes, it is made by a developer for developers.

I you like an automated file based work-flow this project might be for you. It is usable to kick-start a new CMSMS project or it can be applied to existing ones.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Advanced Content
PostPosted: Fri Feb 15, 2019 3:52 pm 
Offline
Forum Members
Forum Members

Joined: Sun Feb 03, 2008 8:14 pm
Posts: 52
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:
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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Advanced Content
PostPosted: Fri Feb 15, 2019 5:21 pm 
Offline
Forum Members
Forum Members

Joined: Sun Feb 03, 2008 8:14 pm
Posts: 52
Not ideal (I'll dust off my OO sometime LOL) but for now this works:

UDT called CGSharedBlocks
Code:
$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:
{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:
   {$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:
{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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting