MyBB Community Forums

Full Version: Variables won't work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Solved.
Still looking for help on this one. If for example enter the variable {$history_date} it won't display anything (yes, i've made it so once a user logins, it will insert the date into the database)

I'm clueless.
Can you show me the template you're using?
Use usercp_end instead for your hook.
Not sure if the hook matters (I think it's fine), but your code is wrong in several other places:
1. You're selecting only the dateline column in the simple_select() query, yet you're trying to use the lastip column. Both need to be selected.
2. $history_date tries to use undefined $loginhistory, which should be $history like in the loop. And why are you using date() instead of MyBB's my_date()?

Also, (int) casting is more preferred than intval(). Your function name is not really unique and may conflict with other plugins.
Solve.d
You didn't show the template as someone requested. Can't tell more without it. The loginhistory database structure would help too. Also, where do you insert {$history}? Are you sure it's inserted correctly?

But another mistake I can see is that the loop goes $mybb->settings['showhistory'] times, but the template is called only one time, even if the setting is 0. $history_date gets overwritten several times and the last value is probably used in the template, which is never going to work as supposed to. A template should be concatenated to a variable several times in the loop so that all records will be displayed.
Solved
Does the plugin install without any errors? Never heard of smallintval/bigintval column types in any DB system we support.

And the template logic is wrong as I suspected - you can't loop through several records and output them only once in a template. You need to separate this:
<tr>
<td class="trow1">{$history_date}</td>
<td class="trow1">{$history['lastip']}</td>
<td class="trow1">{$userinfo['country_name']}</td>
<td class="trow1">{$userinfo['city']}</td>
</tr>
into another template and then concantenate it to a variable each time. Then output that variable in the main template.
Solved