dalenguyen / firebase-wordpress-plugin

A plugin that helps to integrate Firebase to WordPress
https://firebase-wordpress-docs.readthedocs.io
GNU General Public License v2.0
110 stars 31 forks source link

Dynamic inputs for shortcodes #115

Closed satya-securemachines closed 3 years ago

satya-securemachines commented 4 years ago

Hi Dale,

We have been using verion 1.14.0 of your plugin to read and display data from a firestore. It works fine.

We now need a way to dynamically pass a value to your short code. For example below is a shortcode we are using.

[firestore_blocks class='your-class-name' collection_name='TestSet_1' display_fields='Name']

We now need a way to parameterize the collection name being passed to this short code. It could be coming from another collection within the firestore.

We tried the below lines, however this does not seem to work.

[firestore_blocks class='your-class-name' collection_name=' [firestore_blocks class='your-class-name' collection_name='TestSet_2' display_fields='Value']' display_fields='C01']

Could you kindly suggest how we could achieve this?

Thanks in advance,

Satya

dalenguyen commented 4 years ago

Hi @satya-securemachines, for complex tasks, the best way is to write a custom script for it. First is to retrieve the TestSet_2, then when you get the value, start to get the other collection.

https://firebase-wordpress-docs.readthedocs.io/en/latest/developer/add-custom-scripts.html https://firebase.google.com/docs/firestore/query-data/get-data

satya-securemachines commented 4 years ago

Hi Dale,

Thanks for this info. Will try adding a new .js script.

So once we have a value in .js script, how to we pass this on to your shortcodes?

Thanks, Satya

dalenguyen commented 4 years ago

Hi @satya-securemachines, there is no option for passing value to the shortcode that way. However, you can achieve what you need after you got the value without relying on the shortcode.