3-Way Datasource
This is an open discussion with 3 replies, filed under General.
Search
I don't really understand. Would "mario" return all entries beginning with m
? Would no URL parameter only return entries beginning with b
? Is this all pulling from one section, and filtering on the same field?
I'm not sure what you want either. But I'm guessing you just want to filter you entries by a parameter, show some default entries when the parameter is empty and show all entries when the parameter is all. One way to solve this would be to customize your data source and add something like
if (!isset($this->dsParamFILTERS['id_of_field'])) { $this->dsParamFILTERS['id_of_field'] = 'your,default,parameter,values'; } if ($this->dsParamFILTERS['id_of_field'] == 'all') { $this->dsParamFILTERS['id_of_field'] = ''; }
at the beginning of your grab()
method.
@nickdunn: yes, explicit m
and default c
would filter on the same field (I'm using an a reflection filed with the initial, but that's for another post...). /all
would, say, satisfy a required DS parameter, letting a second filterless datasource pull all data from the section.
One thing I failed to mention in the original post: the default c
would not be hardcoded, but set by the user in a static section.
I got it working originally by URL rewriting ^/all
to /home/?all=1
, and making $url-all
a required parameter, but when the redirect is internal, then the ?all=1
is eaten away and the datasource stays silent.
Thanks @klaftertief. I will now try your suggestion.
Let me know if you have any other suggestions, or think that I am grabbing this the wrong way.
Create an account or sign in to comment.
Puzzled:
site.com/mario — shows:
mario, maria, mother, magic, moo
entries.site.com/ — shows:
black, blue, baby
entries from a default selection.site.com/all — shows:
anton, ..., zorro
How would you set this up in a way that does not involve pulling an entire datasource in XML when not needed? And without using ?url=value to show
/all