Jump to content

Recommended Posts

Posted

I am not sure if I am using the api wrong or if something is broken.  Been stuck for a bit.

The page I am on has a page field I am using for a select option.  I am not able to read it with api.

I need to print out its title but it is coming back as empty or null even though it is set.  

$page->BaseStyle->title;

Take a look at the attached screenshot!

Thanks in advance for any help you can give!

post-2339-0-84238800-1457543536_thumb.jp

Posted

Fieldname BaseStyle has Uppercase letters. Try to rename / use only lowercase letters. Check the fieldname in DB, (field_BaseStyle or field_basestyle)

Posted

Case doesnt seem to matter.  If I do this:

echo "<pre>";
var_dump($page->basestyle); //(now all lowercase)
echo "</pre>";

foreach($page as $field => $value) {
    echo "$field = $value <br />";
	
}

It shows this:

NULL

id = 1016 
Design_Settings = 
BaseStyle = 
MiddleStyle = 
Design_Settings_END = 

$page->basestyle->title is also empty.

Posted

You the man!

As soon as I checked  "Make field value accessible from API even if not viewable (see below)*" it showed up!

All I checked was manage access control. What role does the api run as?

Posted

Ah..  My first instinct for an important field is to remove guest access.  :D

Should this api checkbox be enabled by default?  

Or is it common that you would want to block the api from reading roles manged fields by default?
 

Posted

I don't think checking it by default would be sensible. Usually, access is managed by template permissions and hidden/published status on the selectable pages. Any widening of access rights should have to be done explicitly.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...