Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi again, one more quick question!

For the site i'm working on, the client is going to have multiple people posting and would like to have it specify who posted what. Just wondering if there's a way that I can grab the name of the user who posted something. I tried "<cms:show k_user_name />" but that didn't seem to work.

Thanks again in advance!

Andy
Hi,

Couch by itself does not record as to who posted a particular page.

However, we can easily use an editable region (dropdown) that lists all users and can select one from the list. To make things even easier, we can select the currently logged-in user as the default.

Please do the following -
1. Define the following drop-down in your template
Code: Select all
<cms:editable
        name='author'
        label='Author'
        opt_values='list_authors.htm'
        opt_selected = 'current_author.htm'
        dynamic='opt_values | opt_selected'
        type='dropdown'
    />


2. I am attaching a zip containing two snippets. Please place both of them in your couch/snippets folder (or if you have changed this folder in config, in that folder).

3. Refresh your template as super-admin for the changes to persist.

Coming back to the admin-panel, you'll see all your users listed in the drop-down with the currently logged-in automatically selected.

Now on the front-end you can show the selected author as <cms:show author />

Hope this helps. Please let me know.

Attachments

Perfect as always, thanks so much!
Could this be implemented as a standard tag into the core?

Especially when you consider the (pretty good so far I've seen) Blog Functionality, this would be really helpful. If you could loop through Users and even Filter by User Level or similar, this would be a nice bonus.

I do realise this is possible with extending your snippets, but that isn't what Couch is about, right ;)
KK,

Thank you, this script works great!

But I have a problem since I only installed the script about a week ago. When every time I (I guess any visitors) visit the older page where the author not set yet, a default page will automatically be published!

I mean this page -> Default page for blog.php * PLEASE CHANGE THIS TITLE *

How to fix this?

There are hundreds of posts, it will be a tedious job to edit the author one by one on each page. Hopefully, you have a better solution.
@couchso

There are hundreds of posts, it will be a tedious job to edit the author one by one on each page. Hopefully, you have a better solution.
The problem is not that some blog pages are not yet associated with a user.

Problem is that the blog template (like every Couch managed template) requires a default page - if that page is deleted, Couch goes ahead and creates one automatically.

What seems to be happening is that, every time it does so, the admin deletes it and so the cycle continues.

Therefore, please do not delete the "Default page for blog.php * PLEASE CHANGE THIS TITLE *" you mentioned (would be futile as it would only get recreated) -
rather, rename it and use it as an ordinary post
OR (and this is the preferred alternative) -
just edit it and unpublish it from the admin-panel.

This way, this page won't get in your way (e.g. get listed) and would satisfy Couch's requirements.

Hope it helps.
6 posts Page 1 of 1

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 4 guests