Nested Shortcodes? - wordpress

For my WordPress site, I am using both PODS, and WPDataTables to manage my data. With that, I am using WPDT's "placeholder" feature to create dynamic SQL queries that will display different data depending on what user is logged in. Currently, I can ALMOST do everything I need, but not quite. This is more or less what I would like to achieve (var1 = the output of another shortcode):
[wpdatatable id=14 var1=
[pods name="User" template="Company" where="id = {#user.id}"][/pod]]
[/wpdatatable]
This shortcode is working, and will pull back a single number, based on the user that is logged in:
Company: [pods name="User" template="Company" where="id = {#user.id}"]
And this code is working if I hardcode a specific value to var1:
[wpdatatable id=14 var1=5]
Basically, I have two separate shortcodes that work individually, but will not work when put together. I was wondering if something like this would be possible? Or if I needed to maybe think of a new approach. Thanks in advance!
Side Note: I have tried using the "Outerbridge Nested Shortcodes" plug-in without any luck. After talking with the plug-in author, I discovered that this plugin only works for:
[tag-a] [tag-b] [/tag-a]
And not:
[tag-a [tag-b] ]

That's something wpdatatable needs to enable like we do it for pods but that would be around the other way see how it's done for pods: https://pods.io/docs/build/using-shortcodes-pods-templates/

Related

Using handlebars to filter specific products from a JSON object?

Kind of a weird and specific question but here I go.
I can currently pull all my products through YAML and through some really brute-force methods, I would be able to sort the product out by custom fields.
I have a multiple choice wizard the user has to fill and in the end, I get an object that looks something like this:
{
stoneType: ['Granite', 'Quartz', 'Glass'],
stoneFinish: ['Polished', 'Honed'],
stoneConcern: ['Floor Care'],
labels: ['Daily Cleaning', 'Stain Removal']
}
I can't (or at least I don't know how) to get this data into my HTML to use the data stored in my YAML code and render the specific products.
I believe I can solve this issue if I were able to pass the array of products into javascript using some sort of handlebars helper(?) but Bigcommerce doesn't allow for custom helper functions.
I read online that you can bypass this by installing handlebars but that is not working for me.
When I installed handlebars through NPM, I get this error:
GET http://localhost:3000/stencil/00000000-0000-0000-0000-000000000001/dist/theme-bundle.main.js 404 (Not Found)
Is there a way for me to get custom helper functions working or another possible idea to sort & filter the products?
Thank you, appreciate the help.
EDIT: I have also tried manually downloading Handlebars.js including the file but I get the error Handlebars is not defined. I must be doing something wrong...

RssDisplay Extension / Simple Pie

I'm just a little desperate.
I installed the RSS Display extension.
http://typo3.org/extensions/repository/view/rss_display
Everything works fine, but I have just a little understanding problem.
I pull myself with fluid the Author for the current feed.
<feed:item.get value="author"/>
Than i look whats inside.
<f:debug><feed:item.get value="author"/></f:debug>
Thats the result.
SimplePie_Author prototype object
name => 'Name Name' (12 chars)
link => NULL
email => NULL
So what i need it's to get the name of the author.
Unfortunately i am not able to get the value.
I am really new in Fluid, Typo3.
Hopefully someone can help me.
One way to do this, is to create a fluid variable author and assign the author object to it. Then you can access the name using {author.name}.
To create a variable, you could use the ViewHelper <f:alias>, like this:
<f:alias map="{author: '{feed:item.get(value: \'author\')}'}">
{author.name}
</f:alias>
Another way would be to use the extension "vhs", which provides many tools for use with fluid. One of these tools is the ViewHelper <v:variable.set>, which could be used like this:
<v:variable.set name="author" value="{feed:item.get(value: 'author\'}"/>
{author.name}
This has the advantage that you don't need to use the variable within the tags of the ViewHelper.
There are other ways to reach the same goal, without defining variables, but this seems to be the easiest one to me.

wp_list_comments give first and last name

I am using this standard function to displayy comments on a website running Wordpress 4.0:
wp_list_comments();
However, that way comments by registered users are shown with their username instead of their first and last name. This is obviously also a security risk.
Anyway to influence this function to give our first and last names or do I have to do a workaround?
Thanks!
Wordpress will always list the preferred Display Name your users can set in their profile settings. Just have them set it to their preferred name there and you are good to go.

How to OR solr term facets via the search URL in Drupal 7 site?

I have a Drupal 7 website that is running apachesolr search and is using faceting through the facetapi module.
When I use the facets to narrow my searches, everything works perfectly and I can see the filters being added to the search URL, so I can copy them as links (ready-made narrowed searches) elsewhere on the site.
Here is an example of how the apachesolr URL looks after I select several facets/filters:
search_url/search_keyword?f[0]=im_field_tag_term1%3A1&f[1]=im_field_tag_term2%3A100
Where the 'search_keyword' portion is the text I'm searching for and the '%3A' is just the url encoded ':' (colon).
Knowing this format, I can create any number of ready-made searches by creating the correct format for the URL. Perfect!
However, these filters are always ANDed, the same way they are when using the facet interface. Does anyone know if there is a syntax I can use, specifically in the search URL, to OR my filters/facets? Meaning, to make it such that the result is all entries that contains EITHER of the two filters?
Thanks in advance for any help or pointers in the right direction!
New edit:
I do know how to OR terms within the same vocabulary through the URL, I'm just wondering how to do it for terms in different vocabularies. ;-)
You can write a filter query that looks like:
fq=field1:value1 OR field2:value2
Alternatively you can use localparams to specify the query operator:
fq={!q.op=OR}field1:value1 field2:value2
As far as I know, there's not any easier way to do this. There is, in fact, an rather old bug asking for a way to OR the fq parameters...
I finally found a way to do this in Drupal
Enable the fq parameter setting.
Go to admin/config/search/apachesolr/[your_search_page]/core_search/edit or just navigate to the settings of the search page you're trying to modify
Check the 'Allow user input using the URL' setting
URL Syntax
Add the following at the end of the URL: ?fq=tid:(16 OR 38), where 16 and 38 are the term ids

Wordpress variable

I just think about that, easy to do in non cms site, but in wordpress site... i like to know YOUR approach to that problem
I have a BIG site (200 pages)... and at a lot of place, the info#something.com, the 000-000-0000 telephone and send your check to 123 easy street, Canada...
all that email, telephone, and address... should reside in one place (a post or a var) and when you need to insert it you should used the short code [tel] or [email].... but how...
is there a plusgin that can define var, or a tutorial to do that... do you only have to change it ONE for the whole site..
Any idea is welcome.... now, find and remplace is my friend !...
thanks in advance
You could try the Custom Config plugin:
http://wordpress.org/extend/plugins/custom-configs/
It will allow you to create custom global variables that are contained within the CMS (otherwise you'd be declaring these variables within the template config).
Usage to output a variable onto the page would be something like:
<?=get_config('myVariable','default')?>

Resources