Здравствуйте, сделал доп поле text_group для групп пользователей, теперь надо вывести для всех пользователей не зависимо от группы(админ, не реганный)
{If $user->group_id==2 }
<p>{$group->text_group}</p>
{else}
<p>{$user->group_id==15->text_group}</p>
{/if}
Пытаюсь как то так, но не получается
В api пытался через group_text вывести но всеравно ничего
function get_groups(/*group_discount*/$filter = array()/*/group_discount*/ )
{
/*group_discount*/
$order = 'g.discount';
$discount_filter = '';
if (isset($filter['is_discount'])) {
$discount_filter = $this->db->placehold('AND g.is_discount=?', intval($filter['is_discount']));
}
/*/group_discount*/
/*group_visible*/
$filter_for_visible = '';
if (isset($filter['for_visible'])) {
$filter_for_visible = $this->db->placehold('AND g.for_visible=?', intval($filter['for_visible']));
}
/*/group_visible*/
// Выбираем группы
$query = $this->db->placehold("
SELECT g.id, g.name, g.text_group, g.discount, g.is_discount, g.short_name, g.for_visible
FROM __groups AS g
WHERE
1
$discount_filter
$filter_for_visible
ORDER BY g.discount
");
$this->db->query($query);
return $this->db->results();
}
function get_group($id)
{
// Выбираем группу
$query = $this->db->placehold("SELECT * FROM __groups WHERE id=? LIMIT 1", $id);
$this->db->query($query);
$group = $this->db->result();
return $group;
}
function get_group_text($id)
{
// Выбираем группу
$query = $this->db->placehold("SELECT * FROM __groups WHERE id=15 LIMIT 1", $id);
$this->db->query($query);
$group = $this->db->result();
return $group_text;
}
Так же есть админская часть
<?PHP
require_once('api/Simpla.php');
class GroupAdmin extends Simpla
{
public function fetch()
{
$group = new stdClass;
if($this->request->method('post'))
{
$group->id = $this->request->post('id', 'integer');
$group->name = $this->request->post('name');
$group->text_group = $this->request->post('text_group');
$group->discount = $this->request->post('discount');
/*group_discount*/
$group->short_name = mb_substr($this->request->post('short_name'), 0, 10, $this->config->php_charset);
$group->is_discount = (int)$this->request->post('is_discount', 'boolean');
/*/group_discount*/
/*group_visible*/
$group->for_visible = $this->request->post('for_visible', 'boolean');
/*/group_visible*/
if(empty($group->id))
{
$group->id = $this->users->add_group($group);
/*group_visible*/
if ($group->for_visible) {
$this->products->alter_table_add_column_p(intval($group->id));
}
/*/group_visible*/
/*group_discount*/
if ($group->is_discount) {
$this->variants->alter_table_add_column_v(intval($group->id));
}
/*/group_discount*/
$this->design->assign('message_success', 'added');
}
else
{
/*group_visible*/
$group_m = $this->users->get_group(intval($group->id));
if ($group_m->for_visible !== $group->for_visible) {
if ($group->for_visible) {
$this->products->alter_table_add_column_p(intval($group->id));
} else {
$this->products->alter_table_drop_column_p(intval($group->id));
}
}
/*/group_visible*/
/*group_discount*/
$group_m = $this->users->get_group(intval($group->id));
if ($group_m->is_discount != $group->is_discount) {
if ($group->is_discount) {
$this->variants->alter_table_add_column_v(intval($group->id));
} else {
$this->variants->alter_table_drop_column_v(intval($group->id));
}
}
/*/group_discount*/
$group->id = $this->users->update_group($group->id, $group);
$this->design->assign('message_success', 'updated');
}
$group = $this->users->get_group(intval($group->id));
}
else
{
$id = $this->request->get('id', 'integer');
if(!empty($id))
$group = $this->users->get_group(intval($id));
}
if(!empty($group))
{
$this->design->assign('group', $group);
}
return $this->design->fetch('group.tpl');
}
}