modifiedcontent

Field type for a text-based array?

Recommended Posts

Another dumb question:

Is there a field type for a text-based array?

In my case I need to store an array of RSS feeds for SimplePie. Storing that list of links in a textarea - text formatted to look like an array - doesn't work with the script. It works with one link.

The images field is an array. I assumed there would be an equivalent for URLs or text in general.

Or is there another approach for these cases?

Edit:

I guess using the optional (module) Repeater field type is the best solution in this case? I have now a working solution based on that. Still curious about other ideas.

 

Share this post


Link to post
Share on other sites
2 hours ago, modifiedcontent said:

Is there a field type for a text-based array?

You mean JSON? Or Serialized array?

Here are a couple of posts (not all may be directly relevant in your case, though).

 

 

 

 

 

 

 

 

 
  • Like 2

Share this post


Link to post
Share on other sites
Quote

You mean JSON? Or Serialized array?

Either or both! A JSON field would probably be most useful.

I am watching some of those other threads. Simplepie takes input as a list of comma-separated links, not key => value - does that type of array have a name? I managed to make it work with a repeater field.

Share this post


Link to post
Share on other sites

I use FieldtypeYaml module because it is relatively easy to manually edit Yaml. JSON is easy to read but not so easy to manually edit. It is a good choice using FieldtypeYaml for not too complex config fields , I think.

  • Like 1

Share this post


Link to post
Share on other sites

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.

  • Similar Content

    • By Livius
      Hello fellow Process wire Developers!
      Today i have encountered an issue using the repeater where I can't find out how to solve it therefore i am asking for help.
      To be specific, I am trying to get the "file" field working properly in the repeater but i couldn't find a way on how to assign a property of a field that is being used by the repeater.
      download_pdf is the name of the field that i want to access properties from.
      What i wished i could do was something like $download->download_pdf.size or $download->download_pdf->name, something like that but obviously these didn't work
      Hope there is a solution and thanks in advance!
      Best wishes,
      Livius

    • By mrjasongorman
      I've been working with different CMS's for quite a few years now but there was always one thing that bugged me, I never knew how the CMS takes a url and resolves a page ID from it. I knew it was to do with the "slug" but what i couldn't figure out is when it came to sub pages, as the slug only refers to the page itself not the parent pages in the url e.g /parent-page/sub-page.
      The main two CMS's i've worked with are Wordpress and ProcessWire, ProcessWire always has the upper hand when it comes to speed, even a large PW site is tens of milliseconds faster than a fresh Wordpress install.
      With the resolution of urls to pages being (probably) the most used query in a CMS i thought i'd investigate the two different approaches.
      Both ProcessWire and Wordpress split the urls by forward slash to extract the slugs /about/people/ => ['about', 'people'], however ProcessWire takes a completely different approach when it comes to resolving a page ID from these slugs. ProcessWire uses this query: 
      SELECT pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN pages AS parent2 ON (pages.parent_id=parent2.id AND (parent2.name='about')) JOIN pages AS rootparent ON (parent2.parent_id=rootparent.id AND rootparent.id=1) WHERE pages.name='people' AND (pages.status<9999999) GROUP BY pages.id LIMIT 0,1; Resulting in a single item of the page in question including the page's template id. For urls with more parts it looks as though ProcessWire creates more JOINS to essentially walk back up the hierarchy and fully resolve the ID of the correct page. 
       
      Wordpress on the other hand takes a different approach:
      SELECT ID, post_name, post_parent, post_type FROM wp_posts WHERE post_name IN ('about','people') AND post_type IN ('page','attachment'); More elegant looking however it returns a list of potential items. So requires a loop within PHP to walk the hierarchy tree and determine the correct page ID.
      Both queries once cached by MySQL took 19-21ms to return, ProcessWire looks as though it uses this to it's advantage by returning the correct page ID straight from the MySQL cache and doesn't require the extra looping step afterwards.
       
      Interesting to see the different approaches to the same problems.
       
    • By Sonia Margollé
      I have a problem and I don't understand. I have a profield table with different fields and a select field.
      I did like it's instructed and put "value=label".
      But when I'm trying to output the select field with var_dump (to debug),  it's indicated that the field is a string that contains the value.
      Why is it a string ?  when I try  myselectfield->value  or label or title I have an error saying I'm trying to get a property on a non-object ...
      Anyone ? 
    • By cosmicsafari
      Hi all,
      Just wondering if its possible to just add some basic output to my modules config page.
      I was wanting to output a bulleted list of some information which I will be pulling from a third party.
      Retrieving the data is fine i'm just not sure how to output it to the config page?
      From what I can see in the link below, it only seems like you can append form items to the page.
      https://processwire.com/blog/posts/new-module-configuration-options/
    • By mike62
      I'm trying to echo a field from another page, in my footer. I have a Website Settings page (id 1006) with several fields for general site settings, like store hours (field is named store_hours). In the footer, I have this:
      <?php $settingsPage = $pages->get(1006); echo $settingsPage->store_hours; ?> Shouldn't that output the contents of that field? Right now it's printing a "0" (zero) on the page.
      Elsewhere in the same footer template file, I have this code and it works fine:
      <?php $homepage = $pages->get(1); echo $homepage->body; ?> Does it have anything to do with the fact that the field is organized into one of these tabs, at the top of the page editor?
      (disclaimer: I'm new to PW, and have inherited this site from another developer; that's why I don't know how or why some of this stuff is set up the way it is).
      Thanks!