PCuser Posted August 15, 2018 Share Posted August 15, 2018 I have this line of code on one of my templates: $field = $fields->get('artcategories');$all_options = $field->type->getOptions($field); $selected_option = $all_options->get('2'); echo $selected_option->title The line highlighted in red throws the errorNotice: Use of undefined constant - assumed '' in /public_html/site/assets/cache/FileCompiler/site/templates/samplepage.php on line 45 I looked into the issue and it's usually a lack of quotes, presumably it's the getOptions($field) requires quotes but with quotes the script won't work. Edit: I think one of the quotes what copied from elsewhere and was the wrong ansii character @ $all_options->get('2');, i.e the wrong apostrophe, so it was throwing the syntax error. Link to comment Share on other sites More sharing options...
psy Posted August 15, 2018 Share Posted August 15, 2018 @PCuser not sure if it's related but I've often had similar errors when copy/pasting sample code from the PW docs/forums. Maybe it picks up some 'invisible' extra code or spaces? Now I copy/paste to a plain text editor first before adding to my template - same as I'd do for MS Word - and it seems to fix the problem 4 Link to comment Share on other sites More sharing options...
Soma Posted August 16, 2018 Share Posted August 16, 2018 It's not an error but a notice. ? 2 Link to comment Share on other sites More sharing options...
szabesz Posted August 16, 2018 Share Posted August 16, 2018 10 hours ago, Soma said: It's not an error but a notice. Depends on how you look at it ? Strictly speaking it was a Notice, for sure. However, it turned out that it was also a "copy/paste error"... ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now