BomAle Posted June 22, 2016 Posted June 22, 2016 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}"; } } }
bfarber Posted June 27, 2016 Posted June 27, 2016 For what it's worth, this is on a shorter-term list of improvements we intend to make for third party developers. No promises, but it shouldn't be too far off.
BomAle Posted December 2, 2017 Author Posted December 2, 2017 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}}', ] ]); }
bfarber Posted December 4, 2017 Posted December 4, 2017 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.