How to access public / private status? Topic is solved

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
QoQoo
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Mon Feb 15, 2021 4:34 am

How to access public / private status?

Post by QoQoo » Thu Jul 22, 2021 6:05 am

Hello.
Thank you as always.

I create and operate an original article template.

I can get the title of the article with the following script.
$str_title = $this->item->title;

How can I get the public and private flags in the same way?
Last edited by toivo on Thu Jul 22, 2021 7:23 am, edited 1 time in total.
Reason: mod note: moved from 3.x General Questions, retitled

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 23338
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: How to access public / private status?

Post by pe7er » Thu Jul 22, 2021 9:15 am

I would check all the fields that are available in the article item object via:

Code: Select all

echo '<pre>';
print_r($this->item);
echo '</pre>';
It's probably: $this->item->access
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
The best website: https://the-best-website.com

QoQoo
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Mon Feb 15, 2021 4:34 am

Re: How to access public / private status?

Post by QoQoo » Sat Jul 24, 2021 12:44 am

thank you for the advice.
I was able to judge by the [state] property.

[state] => 1 Published
[state] => 0 Private

Regards.

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 23338
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: How to access public / private status?

Post by pe7er » Sat Jul 24, 2021 8:22 am

Actually, state does not have a "Private" option.
State = 0 means unpublished.

The "state" field is for unpublished (0), published (1), archived (2) and trashed (-2)
The "access" field is for Viewing Access Level (in back-end see Users > User Access Levels
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
The best website: https://the-best-website.com


Post Reply

Return to “Joomla! 3.x Coding”