Jump to content

Hook also into cms templates


BomAle

Recommended Posts

Posted

I am try to override the template located on database > display > record (without custom edits or uploads a new template...) I am stopped because \IPS\cms\Theme::i()->getTemplate(...) don't call compileTemplates() when IN_DEV and then I cannot use developer center >_<

tried with theme hook( \IPS\Theme\class_cms_database_display ) with editing file \system\Plugin\Hook.php devTable() : 

				foreach ( \IPS\Theme::load( \IPS\Theme::defaultTheme() )->getRawTemplates( null, null, null, \IPS\Theme::RETURN_ALL_NO_CONTENT ) as $app => $locations )
				{
					foreach ( $locations as $location => $_groups )
					{
						foreach ( $_groups as $group => $data )
						{
							$groups[ $app ][ $app . '_' . $location . '_' . $group ] = "{$location}: {$group}";
						}
					}
				}
				foreach ( \IPS\cms\Theme::i()->getRawTemplates( array(), array(), array(), \IPS\cms\Theme::RETURN_ONLY_TEMPLATE | \IPS\cms\Theme::RETURN_ALL_NO_CONTENT ) as $app => $locations )
				{
					foreach ( $locations as $location => $_groups )
					{
						foreach ( $_groups as $group => $data )
						{
							$groups[ $app ][ $app . '_' . $location . '_' . $group ] = "{$location}: {$group}";
						}
					}
				}

edit.png

  • 1 year later...
Posted

any news on this? I am trying now overriding compileTemplate for inject a custom code:

public static function compileTemplate( $content, $functionName, $params='', $isHTML=TRUE, $isCSS=FALSE, $app=null, $location=null, $group=null )
	{
		if( $functionName == 'theme_cms_database_display_record' or ( $functionName == 'record' and $app == 'cms' and $location == 'database' and $group == 'display' ) )
		{
			$content = static::themeHooks($content,[
				[
					'selector' => 'article',
					'type' => 'add_after',
					'content' => '{{if $poll = $record->getPoll() AND $poll->displayTemplate = array( \IPS\Theme::i()->getTemplate( \'browse\', \'advpolls\', \'front\' ), \'display\' )}}
{$poll|raw}
<br>
{{endif}}',
				]
			]);
		}

 

Posted

What are you ultimately trying to accomplish? I only ask because administrators can rename their templates and create new copies with different keys, so I'm not sure a general hook on a Pages template is really going to typically work.

That said, I don't know what you are trying to accomplish either so I can't say for sure.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...