Forum for discussing general topics related to Couch.
30 posts Page 1 of 3
Hi,

I made a custom Admin Dashboard and i have some problem with the EDIT profile section.

I have User View file where ALL users is listed. And when hovering the NAMES of users i can click to come to EDIT area (new page). Then my User Edit page is showing the user info in data-bound form. But if i click users other than Admin im still getting the Admin info.

Im using the code:

<cms:form
masterpage=k_user_template
mode='edit'
page_id=k_user_id
enctype="multipart/form-data"
method='post'
anchor='0'
>

How can i change the code to get the spessific USER info based on the ID or something!
Hi,

this is in your
Code: Select all
page_id=k_user_id
if you are logged in as a user it will get your user id.

you can use <cms:dump /> on your page to check the variable stored in the k_user_id
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Tomarnst wrote: Hi,

this is in your
Code: Select all
page_id=k_user_id
if you are logged in as a user it will get your user id.

you can use <cms:dump /> on your page to check the variable stored in the k_user_id


I understand this. But when im logged in as Admin i want to change info on other users when clicking the name of user. But i dont know how to set up tje LINK A HREF or if i must change something in the <cms:form masterpage CODE!
hi

I was thinking you had already a list of the users on your page or not ?

if so the link to the user page can be
Code: Select all

<cms:pages masterpage='your users template' >

<a href="<cms:show k_page_link/>">user name here</a>

</cms:pages>


to fetch the user id use this in the pages tag above
Code: Select all
<cms:show k_user_id/>


to change your in your db edit form try to set a variable to page_id=k_user_id

Code: Select all
 <cms:set useredit = "<cms:show k_user_id/>"/>


and use this in your form code

Code: Select all
page_id="<cms:show useredit/>"
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Tomarnst wrote: hi

I was thinking you had already a list of the users on your page or not ?

if so the link to the user page can be
Code: Select all

<cms:pages masterpage='your users template' >

<a href="<cms:show k_user_template/>">user name here</a>

</cms:pages>


to fetch the user id use this in the pages tag above
Code: Select all
<cms:show k_user_id/>


to change your in your db edit form try to set a variable to page_id=k_user_id

Code: Select all
 <cms:set useredit = "<cms:show k_user_id/>"/>


and use this in your form code

Code: Select all
page_id="<cms:show useredit/>"


Hi,

Thanks, i will try this now. Just will tell you how it is now.

I have the user.php listing all users like this:

<cms:pages masterpage=k_user_template page_id=k_user_id >

<td><a href="<cms:show k_user_template/>"><cms:show fullname /></a></td>

</cms:pages>

And i want the HREF link to go to user-edit.php where im fetching all info to edit in a form.

But with the <a href="<cms:show k_user_template/>"> i get sent to index.php and thats wrong.
sorry should be <cms:show k_page_link/>
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
I try to explain again. None of the examples work. I might be that im NUB!

I have users-admin.php - here is all USERS listed.

<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='User Cours Admin' hidden='0' />

<cms:pages masterpage=k_user_template page_id=k_user_id >
<tr>
<th scope="row"><cms:show employee_id /></th>
<td><a href="users-cours-admin-edit.php"><cms:show fullname /></a></td>
</tr>
</cms:pages>

<?php COUCH::invoke(); ?>

Then i have users-admin-edit.php - here i wanna edit the users info

<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='Cours Edit' hidden='0' order='13' />

<cms:set success_msg="<cms:get_flash 'success_msg' />" />
<cms:if success_msg >
<h2> - Endringer ble lagret velykket!</h2>
</cms:if>

<cms:form
masterpage=k_user_template
mode='edit'
page_id=k_user_id
enctype="multipart/form-data"
method='post'
anchor='0'
>

<cms:if k_success >
<cms:db_persist_form />

<cms:if k_success >
<cms:set_flash name='success_msg' value='1' />
<cms:redirect k_page_link />
</cms:if>
</cms:if>

<cms:if k_error >
<font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>

<td>
<cms:input name='fullname' type='bound' class="form-control col-md-10 col-xs-12"/
</td>

<input type="submit" name="submit" value="Save" class="btn btn-primary"/>

</cms:form>

Everthing work, the problem is that i get ADMIN user info no matter witch user i click on.
kimheggen wrote: I try to explain again. None of the examples work. I might be that im NUB!

I have users-admin.php - here is all USERS listed.

<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='User Cours Admin' hidden='0' />

<cms:pages masterpage=k_user_template page_id=k_user_id >
<tr>
<th scope="row"><cms:show employee_id /></th>
<td><a href="users-cours-admin-edit.php"><cms:show fullname /></a></td>
</tr>
</cms:pages>

<?php COUCH::invoke(); ?>

Then i have users-admin-edit.php - here i wanna edit the users info

<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='Cours Edit' hidden='0' order='13' />

<cms:set success_msg="<cms:get_flash 'success_msg' />" />
<cms:if success_msg >
<h2> - Endringer ble lagret velykket!</h2>
</cms:if>

<cms:form
masterpage=k_user_template
mode='edit'
page_id=k_user_id
enctype="multipart/form-data"
method='post'
anchor='0'
>

<cms:if k_success >
<cms:db_persist_form />

<cms:if k_success >
<cms:set_flash name='success_msg' value='1' />
<cms:redirect k_page_link />
</cms:if>
</cms:if>

<cms:if k_error >
<font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>

<td>
<cms:input name='fullname' type='bound' class="form-control col-md-10 col-xs-12"/
</td>

<input type="submit" name="submit" value="Save" class="btn btn-primary"/>

</cms:form>

Everthing work, the problem is that i get ADMIN user info no matter witch user i click on.


The problem is you're using
Code: Select all
page_id=k_user_id
on the form, this will grab the user_id of the LOGGED in user, not the user you've selected from the list. You should use a get tag to grab the user id of the user you've selected to edit from the list. Then use that in the form page_id, that will grab the correct info.
Image
Bartonsweb wrote:
kimheggen wrote: I try to explain again. None of the examples work. I might be that im NUB!

I have users-admin.php - here is all USERS listed.

<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='User Cours Admin' hidden='0' />

<cms:pages masterpage=k_user_template page_id=k_user_id >
<tr>
<th scope="row"><cms:show employee_id /></th>
<td><a href="users-cours-admin-edit.php"><cms:show fullname /></a></td>
</tr>
</cms:pages>

<?php COUCH::invoke(); ?>

Then i have users-admin-edit.php - here i wanna edit the users info

<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='Cours Edit' hidden='0' order='13' />

<cms:set success_msg="<cms:get_flash 'success_msg' />" />
<cms:if success_msg >
<h2> - Endringer ble lagret velykket!</h2>
</cms:if>

<cms:form
masterpage=k_user_template
mode='edit'
page_id=k_user_id
enctype="multipart/form-data"
method='post'
anchor='0'
>

<cms:if k_success >
<cms:db_persist_form />

<cms:if k_success >
<cms:set_flash name='success_msg' value='1' />
<cms:redirect k_page_link />
</cms:if>
</cms:if>

<cms:if k_error >
<font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>

<td>
<cms:input name='fullname' type='bound' class="form-control col-md-10 col-xs-12"/
</td>

<input type="submit" name="submit" value="Save" class="btn btn-primary"/>

</cms:form>

Everthing work, the problem is that i get ADMIN user info no matter witch user i click on.


The problem is you're using
Code: Select all
page_id=k_user_id
on the form, this will grab the user_id of the LOGGED in user, not the user you've selected from the list. You should use a get tag to grab the user id of the user you've selected to edit from the list. Then use that in the form page_id, that will grab the correct info.


Ah, i see. But then can you please tell me how to do that?
I was hoping you'd try yourself, but here you go - try this:

users-admin.php

Code: Select all
<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='User Cours Admin' hidden='0' />

<cms:pages masterpage=k_user_template page_id=k_user_id >
<tr>
<th scope="row"><cms:show employee_id /></th>
<td><a href="users-cours-admin-edit.php?id=<cms:show k_page_id />"><cms:show fullname /></a></td>
</tr>
</cms:pages>

<?php COUCH::invoke(); ?>


users-admin-edit.php

Code: Select all
<?php require_once( '../admin/cms.php' ); ?>
<cms:template title='Cours Edit' hidden='0' order='13' />
<cms:set edit_user="<cms:gpc 'id' />" />
<cms:set success_msg="<cms:get_flash 'success_msg' />" />
<cms:if success_msg >
<h2> - Endringer ble lagret velykket!</h2>
</cms:if>

<cms:form
masterpage=k_user_template
mode='edit'
page_id=edit_user
enctype="multipart/form-data"
method='post'
anchor='0'
>

<cms:if k_success >
<cms:db_persist_form />

<cms:if k_success >
<cms:set_flash name='success_msg' value='1' />
<cms:redirect k_page_link />
</cms:if>
</cms:if>

<cms:if k_error >
<font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>

<td>
<cms:input name='fullname' type='bound' class="form-control col-md-10 col-xs-12"/
</td>

<input type="submit" name="submit" value="Save" class="btn btn-primary"/>

</cms:form>
Image
30 posts Page 1 of 3
cron