Hello,
how can you get the admin id (id = 1 )
exactly in the file admin /view/template/user/user_from.tpl want to admin id = 1 could not change the firstname and lastname
I checked if $ user_id ( [ ' user_id '] == '1') {
but unfortunately it did not work
how can you get the admin id (id = 1 )
exactly in the file admin /view/template/user/user_from.tpl want to admin id = 1 could not change the firstname and lastname
I checked if $ user_id ( [ ' user_id '] == '1') {
but unfortunately it did not work
Code: Select all
$this->user->getId()
use that in the controller, not the template file if you are using OpenCart 2.
code snippet for oc2.2
controller:
tpl:
controller:
Code: Select all
$this->user = new Cart\User($this->registry);
$data['admin_id'] = $this->user->getId();
Code: Select all
if ($admin_id == 1) {
// admin_id is 1
} else {
// admin_id is NOT 1
}
You can't control the weather, but you can change your mood.
You can't modify the visage, but you can show your smile.
You can't command someone else, but you can hold yourself.
You can't forecast tomorrow, but you can using today.
You can't obtain thanks, but you can exert yourself in everything.
OCEXTENSION.COM - YOUR PROFESSIONAL OPENCART EXTENSION STORE
You can't modify the visage, but you can show your smile.
You can't command someone else, but you can hold yourself.
You can't forecast tomorrow, but you can using today.
You can't obtain thanks, but you can exert yourself in everything.
OCEXTENSION.COM - YOUR PROFESSIONAL OPENCART EXTENSION STORE
did you add it into the controller? You need to add the codes into the controller first.
is the correct code$data['admin_id'] = $this->user->getId();
i add i controller admin/controller/user/user.php
and in admin/viev/template/user/user_from.tpl
and all the time the same error
Notice: Undefined variable: admin_id in admin/view/template/user/user_form.tpl on line 55
Code: Select all
public function edit() {
$this->load->language('user/user');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('user/user');
$data['admin_id'] = $this->user->getId();
Code: Select all
<?php if ($admin_id == 1) { ?>
<input type="text" name="firstname" value="<?php echo $firstname; ?>" placeholder="<?php echo $entry_firstname; ?>" id="input-firstname" class="form-control"/>
<?php } ?>
Notice: Undefined variable: admin_id in admin/view/template/user/user_form.tpl on line 55
first of all that code need to be placed inside a getForm(), and second i was misunderstanding at first, i thought you want to show on front end and get the admin id. however..inside your controller just after "protected function getForm() {" put below code
Code: Select all
$data['admin_id'] = isset($this->request->get['user_id']) ? $this->request->get['user_id'] : '';
You can't control the weather, but you can change your mood.
You can't modify the visage, but you can show your smile.
You can't command someone else, but you can hold yourself.
You can't forecast tomorrow, but you can using today.
You can't obtain thanks, but you can exert yourself in everything.
OCEXTENSION.COM - YOUR PROFESSIONAL OPENCART EXTENSION STORE
You can't modify the visage, but you can show your smile.
You can't command someone else, but you can hold yourself.
You can't forecast tomorrow, but you can using today.
You can't obtain thanks, but you can exert yourself in everything.
OCEXTENSION.COM - YOUR PROFESSIONAL OPENCART EXTENSION STORE
Who is online
Users browsing this forum: Bing [Bot] and 16 guests