- Posts: 130
COMMUNITY FORUM
Author can't view his own unpublished item
- Steven Trooster
- Topic Author
- Offline
- Premium Member
Less
More
8 years 1 week ago - 8 years 6 days ago #159251
by Steven Trooster
Replied by Steven Trooster on topic Author can't view his own unpublished item
I've come up with a hack to let users view their own articles, before the article is published. (This was an overwhelming request from the authors on my site) This is important, because the author wants to see the final result of the article, before it goes online.
What I've done is changed the following in Components/com_K2/views/item/view.html.php:
In lines 113 and further (// Published check) change the subsequent lines from
to
So the whole piece of code looks like:
The code could use some more refinement, so an authorized user, like an admin or an editor can preview all unpublished articles.
(I've done some testing on V3, but bringing the admin to the frontend is not the same as a live preview of the article)
What I've done is changed the following in Components/com_K2/views/item/view.html.php:
In lines 113 and further (// Published check) change the subsequent lines from
if (!$item->published || $item->trash)
if ((!$item->published || $item->trash) AND $item->created_by != $user->id)
So the whole piece of code looks like:
// Published check
if ((!$item->published || $item->trash) AND $item->created_by != $user->id)
{
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if (($item->publish_up != $nullDate && $item->publish_up > $now) AND $item->created_by != $user->id)
{
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if (($item->publish_down != $nullDate && $item->publish_down < $now) AND $item->created_by != $user->id)
{
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if ((!$item->category->published || $item->category->trash) AND $item->created_by != $user->id)
{
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
The code could use some more refinement, so an authorized user, like an admin or an editor can preview all unpublished articles.
(I've done some testing on V3, but bringing the admin to the frontend is not the same as a live preview of the article)
Last edit: 8 years 6 days ago by Steven Trooster. Reason: Added the name of the file that has been altered
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 6 days ago #159259
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Author can't view his own unpublished item
It looks nice but if you add the Super User's group in the check it will be better :)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Steven Trooster
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 130
8 years 5 days ago #159280
by Steven Trooster
Replied by Steven Trooster on topic Author can't view his own unpublished item
I would suggest a setting for users groups that would allow a the users in that group to view unpublished items. Not just super users. In my case editors check articles before they are published.
This would require more coding. In the list view unpublished articles aren't visible, so an editor will not be able to see these articles in the frontend. Only an author can see his own (unpublished) articles.
This would require more coding. In the list view unpublished articles aren't visible, so an editor will not be able to see these articles in the frontend. Only an author can see his own (unpublished) articles.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 5 days ago #159306
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Author can't view his own unpublished item
A Super user imho should be able to see all items (if he/she is dealing with the content) this is why I suggested that that groups should see these items as well.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Steven Trooster
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 130
7 years 2 months ago #163791
by Steven Trooster
Replied by Steven Trooster on topic Author can't view his own unpublished item
Too bad the recent K2 update still doesn't have an option for authors to preview their own (draft) articles…
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 2 months ago #163829
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Author can't view his own unpublished item
In the default template the check is there,
github.com/getk2/k2/blob/master/components/com_k2/templates/default/user.php#L95
Make sure that you are not stripping these items from your overrides.
github.com/getk2/k2/blob/master/components/com_k2/templates/default/user.php#L95
Make sure that you are not stripping these items from your overrides.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Steven Trooster
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 130
7 years 2 months ago #163853
by Steven Trooster
Replied by Steven Trooster on topic Author can't view his own unpublished item
I see. It's quite difficult when functionality is in a template. Makes it hard to update your own template, since you have no clue what's been updated in the core and what in de default template.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 2 months ago #163860
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Author can't view his own unpublished item
Everything has to be displayed in the frontend. This is a feature that has to be represented in the frontend as well.
This has been a part of the core for many years.
This has been a part of the core for many years.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.