Jump to content

Recommended Posts

In the Doc it says:

Quote

Separate Option Values

By default only titles are kept with each option. If you want to maintain a separate value and title, enter your option in the format value|title (for new options) or 123=value|title (for existing options that already have an ID assigned). The text for value and title will be kept as separate $option->value and $option->titleproperties from the API. These properties can also be independently queried to find pages from the API.

I have an options field (options_colors) configured like this:

Quote

1=red|number1
2=blue|number2
4=green|number4
5=grey|number5
6=beige|number6

I want to have a query returning only pages with the VALUE 'red'. This is a query that works:

$newsentries = $pages->find('template=news-entry,options_colors=number1,sort=-created,limit=16');

this is a query which does not work

$newsentries = $pages->find('template=news-entry,options_colors=red,sort=-created,limit=16');

How do I query for 'red' instead of the title for the value?

Share this post


Link to post
Share on other sites

Try options_colors.title, options_colors.value (or even options_colors.name)

Or use page-references instead.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By rolisx
      Hi Guys,
      Just finished a website locally and wanted to upload it on the webserver of my customer. I got a server 500 error. Now, the guidelines of the hoster (world4you.com) does not allow "Options" in the htaccess-file. So, when I uncomment these:
      Options -Indexes
      Options +FollowSymLinks
      the site is visible, but the content won't show and no links are available. Not sure if I need the Symlinks-part but I guess I need a workaround for the Index-part. Can anybody help here? I need the website up and running asap....
      Thanks!
      Roli
    • 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 jploch
      Hi! 
      this should be easy, but I can't get it to work.
      I have a repeater with events.
      Every event has an option-field with multiple checkboxes.
      To filter the events on the frontend I have a script, that uses the class names to filter the results (an event can have multiple categories).

      Now I just want to add every checked option (title) to use as my class name.
      This is what I have so far, wich only gets the first title.
      foreach($page->events as $event) { $tags = $event->options->title; echo "<div class='size1of2 {$tags}'>"; echo "<img src='{$event->image->url}'>"; echo "{$event->text_editor}"; echo "</div>"; }
      I know there is an example with a foreach, but how would I use it in this context?
      foreach($page->countries as $country) { echo "<li>$country->title</li>"; }
       
    • By pppws
      hey there,
      i'm using processwire for the first time, so maybe it's a dumb question. but i'm trying to have an options field which values are the users of the processwire. i don't need the values to be displayed, it's just for the administration of the page. but each time a new user is created / a user is deleted the options field should be updated automatically. is something like that possible?
×
×
  • Create New...