MyBB Community Forums
[Solved] Template Marker is not replaced {marker} - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: [Solved] Template Marker is not replaced {marker} (/thread-201017.html)



[Solved] Template Marker is not replaced {marker} - demonking - 2016-09-12

Hello,

i'm trying to program a plugin for my mybb Page, but somehow it's now working.
The Plugin is named scrolling_gallery and this is the code:


if(!defined('IN_MYBB'))
        die('This file cannot be accessed directly.');

$plugins->add_hook('index_start','scrolling_gallery');

function scrolling_gallery(){
        global $mybb, $templates, $scrolling_gallery;
        $str = 'hello world';
        $scrolling_gallery=null;
         eval('$scrolling_gallery="' . $str . '";');
}

function scrolling_gallery_info()
{

        return array(
                "name"              => "Scrolling Gallery",
                "description"       => "Nothing interesting here",
                "website"           => "",
                "author"            => "Denis D",
                "authorsite"        => "Under Construction!",
                "version"           => "1.0.0",
                "compatibility"     => "18*",
                "guid"              => "",
                );
}

In the template I have added {scrolling_gallery} and like I read, that should work.
But nothing happend...

MyBB Version :1.8.7

Someone an idea?

Edit:

Maybe I clearify "nothing happened".
Nothing showed on the Page, where my default string should appear.
When I add a return-Statement, the site is blank "like i thought" (in this moment)


RE: Template Marker is not replaced {marker} - .m. - 2016-09-12

{$scrolling_gallery} should work on the index template
in general, $ is used for the variables


RE: Template Marker is not replaced {marker} - Sazze - 2016-09-12

{$scrolling_gallery} will work.


RE: Template Marker is not replaced {marker} - demonking - 2016-09-12

Also tried {$scrolling_gallery}  but no changes.

But ".m." have said , it will only work on the index template, this also includes subtemplates?

The template "{$scrolling_gallery}" is called is named "header"



<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
lang.no_new_posts = "{$lang->no_new_posts}";
lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>

<!--LIGHTBOX COPYRIGHTS AT THE END OF THE CODE-->
<link href="css/lightbox.css" rel="stylesheet">

</head>
<body>
{$header}
<div class="forum"><br />
{$dvz_shoutbox}
{$forums}
</div>



RE: Template Marker is not replaced {marker} - .m. - 2016-09-12

Quote:$plugins->add_hook('index_start','scrolling_gallery');
it is coded to work on index related templates through index_start hook

to get it on the header, you have to use a global hook (eg. global_start)

see plugin hooks and plugins & hooks explained


RE: Template Marker is not replaced {marker} - demonking - 2016-09-12

Thank you very much .m.
Now I see, that I misunderstood the hooks Smile