I am displaying JSON data dynamically on template and I would like search that dynamic content using search option. Any solution in Expression Engine???
By its very nature, no. You're using JSON data dynamically, i.e. you're loading it when the page is viewed, its not stored at all.
Search works by querying the DB tables (or rather the index but I won't get too deep here), this works becasue all the data is there in one place.
One suggestion (short of pulling in all JSON data and searching that) is to cache your JSON calls inside a Channel. Something like this:
- Set up a Channel with a text field and a text area field.
- When you call a piece of JSON data, save the URL to the textfield and the result to the textarea
- When you search, let the text area be searchable, your search results will now include entries in that channel that might have (i.e. last time they where called) the keyword in them.
- When displaying the search results, call the JSON URL, double check the keyword is still in there and if it is show your result, if not step over it.
It's just a thought, of course you have the issue that you can only get results from the last call of the JSON url, there's no guarantee the dynamic content will still contain the word.
You'll also need to consider the title/url_title of your caching channel, so that you overwrite existing entries for the same URL. one option would be to alphanumeric the url and use that as a title code.
You could also get really clever, set up a template that polls all the JSON URL's you are using in a loop, and updates your channel entries accordingly. Set a cron job up to hit that template once/twice a day and get a nice little refresh system going on...
Just a brain dump for you, who know it might give you a good idea of how to proceed!