Closed UrchenkoV closed 4 years ago
Hi,
The items do remain in the same order, after saving. When you go back into the Customizer, all the 'Selected' items are placed first, but they're still in the same order in which you saved them. Only the 'selected' controls are saved to the database. There's no need for me to save the items that aren't selected, and since they're not selected, it doesn't matter if they appear after all the other items.
You can learn how to use this control by reading the readme file or by having a read through Part 2 of my Customizer Developers Guide.
@maddisondesigns
I mean, how do I display this sort on a page? You don't have this example in your documentation.
Have a look at my Customizer Custom Controls Sample Theme, which is mentioned in the readme file. It gives you examples of how to use every single one of my Custom Controls. In particular, take a look at the front-page.php
template to see how to retrieve that value from the database, and what it looks like.
@maddisondesigns Hello.
Tell me, how do I write code to output the code of the selected elements in the order in which they stand? The code that is written on your site does not show how to use the received data.
As I said above, there is example code in my sample theme which shows how to retrieve the data for that control. It shows you the exact string that is stored in the database.
As I also mentioned, the control will only save the items that are selected. It doesn't save the order of every single item, only those items that have been selected.
So for example, it might return a string something like this:
In your example image above, the string saved in the database may look something like "Button,Search,Text/HTML,WooCommerce"
(obviously, this depends on what values you passed to the control).
It's entirely up to you, what you do with that data once you retrieve it from the database.
@maddisondesigns I mean, how to use this data. How do I display items on the page in the order in which they are received? If they were received as an array, it would be possible to output them in a loop, but here is a string, how do I use this string? Write an example of how to use it. Thanks.
I would really recommend brushing up some basic php knowledge if you intend on coding for the Customizer. If you have a comma delimited string, you can use the PHP explode()
function to convert it to an array of strings which you could then easily loop through.
Thank you.
Hello.
Make sure that the items remain in place after saving. Currently, when saving, the selected items move up, and those that are not marked move down. Make sure that the elements are arranged in the order in which they were set by the user or by default regardless of whether they are selected or not.
How do I use this control? How can I use it to display a meta article, for example?
Thanks.