MyBB Community Forums

Full Version: Template Variables - am I too stupid?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

the documentation states that 

$user['favorite_colour'] = 'Blue';

would be enough to access template variables.
I tried to set additional variables now into my postbit template, the following function is bound to the "postbit"-Hook:
function set_post(&$post) {
$post['message'] = 'testingthis';
$post['myArrayKey'] = 'Spaceship';
}
The Message is set to "testing this", as it should.
But if I use my own, (previously non-existent) array key, I'm not able to access it via {$post['myArrayKey']}.
What am I doing wrong?

With kind regards,
levarg
It should work if you're using it in correct template(s), but of course you didn't mention where you're trying to place it.
I'm using the postbit hook and tried both the postbit and postbit_avatar template. It's a custom avatar URL i'd like to set
It won't work in postbit_avatar because the hook is called after the template is evaluated. It should work with postbit though - can't tell more without seeing the code you're using.
Hey Destroy666 (Is that a reference to the australian Metal Band Deströyer666?),

thanks for your response!
That explains why it didn't work, but I'm fighting another problem at the moment that I just can't derive where it's coming from:
I simply added "<div>test</div>" into the postbit template to see if it shows up in the forums, but nothing happens, at all. There's no div "test" existing in the entire DOM. I am using a custom design, but I tried that both in the Default Template postbit and in the Custom postbit.
Any Idea what I'm doing wrong here?
Well, that's most likely a caching problem.

(2016-01-29, 11:16 AM)levarg Wrote: [ -> ]Is that a reference to the australian Metal Band Deströyer666?

Never heard.
I reloaded the cache several times already - no changes.
Caching was also the first thing I was thinking of, but looks like that's not the problem.
Is there any possibility of default templates "refreshing" out of some scripts every time instead of the database?

I'll now try to manually delete the cache folder on my server and see if that helps, maybe MyBB's function to do that is broken.

edit: Moving the cache/theme/ folder to cache/theme___/ resulted in the forum entirely breaking, even rebuilding didn't do anything.
Do you have any idea? I really LOVE this software and appreciate its extendability, but I'm stuck at the very basics at the moment Sad

edit2: Alternatively, I could just use JS to code my wanted plugins - should work fine either.

edit3: Just realized my changed to postbit_avatar take place, but my changes to postbit don't.