Nudaii
Well-known member
howdy i am working on a addon for my forum to add pets to posts, the addon works as in data displays correctly, but while it allows posts to submit it causes a java console error, looking at my code i cant find whats causing it, also i know the method isnt ideal for how it picks whick pt to display isnt ideal, so any help be awesome!
Listener
Controller
Template code - not ideal, as the way to decide which pet to show kinda hacky, inline styling etc fixed later.
It shows the correct info per user, , but when making a new post it causes a "console error" yet not error shows in the console.
any suggestions anyone? the error only occurs when the template (foreach) code in, so not a direct controller issue i presume, but rather something related to the param in the controller?
Listener
Code:
<?php
class Nudaii_Petz_Listener_PostPetz {
public static function loadClassListener($class, &$extend) {
if ($class == 'XenForo_ControllerPublic_Thread') {
$extend[] = 'Nudaii_Petz_ControllerPublic_PostPetz';
}
}
}
?>
Code:
<?php
class Nudaii_Petz_ControllerPublic_PostPetz extends XFCP_Nudaii_Petz_ControllerPublic_PostPetz
{
//This is the action that spawns the function, in this case viewing a post.
public function actionIndex()
{
//connect to Database
$db = XenForo_Application::getDb();
$Petz_in_Posts = $db->fetchAll("SELECT * FROM `xf_petz`");
$response = parent::actionIndex();
$response->params += array('PetzinPosts' => $Petz_in_Posts);
//Finish up and push to Template
return $response;
}
}
?>
Code:
<xen:foreach loop="$PetzinPosts" value="$PetzinPostsVar">
<xen:if is="{$user.user_id} == {$PetzinPostsVar.user_id}">
<div class="nudaii_postbit_petz_wrapper">
<div class="nudaii_postbit_petz_stats">
<div style ="Color:white; font-size:18px;">Name: {$PetzinPostsVar.pet_name}</div>
<div style ="Color:white; font-size:18px;">Age: {$PetzinPostsVar.pet_age} Days Old</div>
<div id="nudaii_petz_myPetzPage_pet_bars">
<div class="nudaii_stat_mypetz_p" id="nudaii_stat_hunger">
<b>Hunger: <font style="color:green;">{$PetzinPostsVar.pet_hunger}</font>/100</b>
</div>
<div class="nudaii_stat_mypetz_p" id="nudaii_stat_thirst">
<b>Thirst: <font style="color:blue;">{$PetzinPostsVar.pet_thirst}</font>/100</b>
</div>
<div class="nudaii_stat_mypetz_p" id="nudaii_stat_health">
<b>Health: <font style="color:red;">{$PetzinPostsVar.pet_health}</font>/100</b>
</div>
<div class="nudaii_stat_mypetz_p" id="nudaii_stat_happiness">
<b>Happiness: <font style="color:orange;">{$PetzinPostsVar.pet_happiness}</font>/100</b>
</div>
</div>
</div>
<div class="nudaii_postbit_petz_avatar">
<xen:if is="{$PetzinPostsVar.pet_sex} == 0">
<img src="Nudaii/Petz/Pets/{$PetzinPostsVar.pet_type}.png" width="180px" height="180px"/>
<xen:else />
<img src="Nudaii/Petz/Pets/{$PetzinPostsVar.pet_type}_female.png" width="180px" height="180px"/>
</xen:if>
</div>
</div>
</xen:if>
</xen:foreach>
It shows the correct info per user, , but when making a new post it causes a "console error" yet not error shows in the console.
any suggestions anyone? the error only occurs when the template (foreach) code in, so not a direct controller issue i presume, but rather something related to the param in the controller?