Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Valtasar Posted October 7, 2017 Posted October 7, 2017 Hi, I wrote a theme hook to add info in topic theme and then I edited the corresponding hook file as follows to add $my_content in the theme: class covers_hook_topics_header extends _HOOK_CLASS_ { /* !Hook Data - DO NOT REMOVE */ public static function hookData() { // CODE TO produce $my_content HERE return array_merge_recursive( array ( 'topic' => array ( 0 => array ( 'selector' => '#elClubContainer > div.ipsColumns > div.ipsColumn.ipsColumn_fluid > div.ipsPageHeader.ipsClearfix', 'type' => 'add_inside_start', 'content' => $my_content ), ), ), parent::hookData() ); } Although this works, I would like to use the $topic (parameter from the topic theme) in my code above to produce $my_content. Is there any way to access this variable in hookData?
Martin A. Posted October 7, 2017 Posted October 7, 2017 Why would you need to generate the content on the "outside"? You can use raw PHP in the content box, where you'll then have access to $topic, and all other variables that may exist in a template.
Valtasar Posted October 7, 2017 Author Posted October 7, 2017 Thanks Martin! You were right and it worked like a charm, first by editing the template and then also by using the block in the theme hook! I was not so experienced with the template/PHP syntax, so after many unsuccessful tries I thought this was almost impossible, but after I read the template guide better and checked a few examples it was finally easy to do what I wanted-much simpler than IPB3 (although escaping and syntax may be tricky some times)! I should check more often the template guide, not only the developer guides.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.