Settingspages doesn't work as expected
- This topic has 12 replies, 2 voices, and was last updated 3 years, 2 months ago by
Long Nguyen.
-
AuthorPosts
-
March 1, 2022 at 10:47 PM #34215
[email protected]
ParticipantI have a big problem with settingspages and I have made a pastebin with code
https://pastebin.com/A3RQZiB1Here you can see what happens: https://update3.ccmp.nl/test/
Explanation:
Settingspage 'Website' / '175' with custom fields won't show data in MB View.
When I add a php code manually (see pastebin) I retrieve the postID (or all other data).
When I insert a field using MB View I don't retrieve the postID (or all other data).I have make a new settingspage ('algemeen' / 'algemeen') and add a customfield to that.
When I insert a field using MB View I retrieve the PostID (or all other data).I really don't understand what is wrong. Please can you help me? This drive me crazy.
Cees
March 2, 2022 at 12:54 PM #34226Long Nguyen
ModeratorHi Cees,
Can you please share the code that creates the custom fields and settings page on your site?
March 2, 2022 at 1:19 PM #34227[email protected]
ParticipantMarch 3, 2022 at 10:49 AM #34247Long Nguyen
ModeratorHi Cees,
The homepage news item field is a top field, so no need to access it via a group subfield. Your current code
{% set group = attribute( site, '175' ) %} {% set field = attribute( group, 'ws-dp--hp_newsitem' ) %} <b>Value: {{ field.ID }}</b>
the correct one
{% set field = attribute( site.Website, 'ws-dp--hp_newsitem' ) %} <a href="{{ field.url }}">{{ field.title }}</a>
just like the new settings page
Retrieve from the 'new settingspage' with algemeen / algemeen {% set field = attribute( site.algemeen, 'al--hompage_blogitem' ) %} <b>Value: {{ field.ID }} </b> {% set field = attribute( site.algemeen, 'al--hompage_blogitem' ) %} <b>{{ field.title }} </b>
March 3, 2022 at 12:34 PM #34254[email protected]
ParticipantHi Long,
Thanks. But it is the ‘insert field’ button that generates the code for me. That is strange. The code on algemeen is diffeerent indeed but both comes from ‘insert field’. Can you explain this?
Cees
March 4, 2022 at 10:24 AM #34288Long Nguyen
ModeratorHi,
Please try to re-save the settings page "Website" and re-select the location settings page of the field group then insert the field in View again. 175 looks like a post ID instead of the option name "Website".
Let me know how it goes.
March 4, 2022 at 1:59 PM #34293[email protected]
ParticipantDone but is doesn't work:
{% set group = attribute( site, '175' ) %}
{% set field = attribute( group, 'ws-dp--hp_newsitem' ) %}
{{ field.title }}{% set field = attribute( site.algemeen, 'al--hompage_blogitem' ) %}
{{ field.title }}175 is the value that stays in the Settings Page ID box in the builder. It is generated when I make the settingspage, not choosen by me.
March 4, 2022 at 2:00 PM #34294[email protected]
ParticipantI hope it is possible to take longer time to look at the problem. Waiting time with another part of the world is 24 hour. Maybe you will login to the site and look what is happen.
March 4, 2022 at 2:27 PM #34295Long Nguyen
ModeratorHi,
Ok, please share your site credentials via the contact form. I will take a closer look.
https://metabox.io/contact/March 4, 2022 at 2:31 PM #34298[email protected]
ParticipantHi,
Send it
March 4, 2022 at 9:45 PM #34310Long Nguyen
ModeratorHi,
Can you please re-check this issue? I've changed the settings page ID from 175 to website and re-select the location of the field group to Website and it works in View. Screenshot https://monosnap.com/file/l7BFlJfyH8AVrWWEJOml9zHccfFWWM
March 4, 2022 at 10:42 PM #34312[email protected]
ParticipantHi Long,
Changing the ID does fully break my site on other places. As example Oxygen uses the ID, and php code like the RWMB where I have manually add the settings_id to 175.
So yes, the problem in the view is fixed but I have 10 websites where the ID is 175.
I haven't set the value to 175 but when I add the settingspage it is set.
What to do?
Cees
March 4, 2022 at 11:04 PM #34313Long Nguyen
ModeratorHi,
The ID 175 populated automatically from the post ID when you didn't add the setting title or add it after publishing the setting page. For now, you can use the helper function to get the value
{% set field = mb.rwmb_meta( 'ws-dp--hp_newsitem', { object_type: 'setting' }, 'Website' ) %} <b>Value: {{ field }}</b>
Follow the documentation https://docs.metabox.io/extensions/mb-settings-page/#getting-field-value
I will inform the development team to check and fix the issue in this case.
-
AuthorPosts
- You must be logged in to reply to this topic.