Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Nicolas
  2. F2C article templating
  3. Tuesday, 21 November 2017
  4.  Subscribe via email
Hi, I am quite new to this, so sorry if this is obvious:

What is the correct syntax to insert a SQL query into a template?

My template so far is:

<h3>{$EINTEILUNG_CAPTION}</h3>
{ldelim}module title="Einteilung {$ALIAS}" style="gantry" moduleclass_sfx=“simplelist”{rdelim}
<br>
[cb:userfield field="cb_{$ALIAS}" /]
<br>

and next, I would like to add a query that looks somewhat like

SELECT movement FROM #__repertoire WHERE work="{$Alias}"

Could you point me in the right direction? Thanks!

Best,

N
Responses (6)
F2C webmaster Accepted Answer Pending Moderation
Hi Nicolas,

First things first. Which versions are you using?
Next, what is it you are trying to do? Not in code but in writing, maybe with bit of workflow etc.
Next, SQL queries don't go into the template .... we have two Database lookupi fields which you can add to your form.
http://documentation.form2content.com/f2c-field-types/database-lookup-field-single-select

Regards,
Patrick
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Nicolas Accepted Answer Pending Moderation
Hey Patrick,

thanks for your quick reply!

I am using Form2Content PRO 12, just downloaded it a few days ago.

In my table #__repertoire I have a list of musical works, they have different movements each - I attached a screenshot.

Now, every article is going to relate to a musical work (example: martin_messe). There are a lot of modules and plugins that all have information about that musical piece that I would like to display and they all relate to this string (here: martin_messe) - that's why in my template example - I substituted the string "martin_messe" with a f2c field $ALIAS - the plugin {ldelim}module title="Einteilung {$ALIAS}" style="gantry" moduleclass_sfx=“simplelist”{rdelim}

I have been experimenting with the Database lookup fields, that works beautifully, when I put in a concrete value for "work". The query is simple:

SELECT movement FROM #__repertoire WHERE work=martin_messe

Is it possible to make it dynamic at this point already? so something like

SELECT movement FROM #__repertoire WHERE work={$ALIAS}

I hope I make myself clear?

Thanks for your time!

N
Attachments (1)
F2C webmaster Accepted Answer Pending Moderation
Hi Nicolas,

I understand your situation. Getting the "variable" into the query is tricky. At the moment we have variables like loged in userid available. I also think that this might not be the correct way.

Your articles relates to a specific work. So in your article you want to set this relation. If you use the database lookup field you can query your table and SELECT the WORK.

You than have the Variable for that work available in your template.

Hope it makes sense and is also what you are looking for.

Regards, Patrick
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Nicolas Accepted Answer Pending Moderation
Hi, thanks. The trouble is, it does not stop there, once I selected the work (which would be my $ALIAS, precisely), I want to get more information from the data base ...

Could one create a plugin that includes the sql query and put that in the template, like I did for [cb:userfield field="cb_{$ALIAS}" /] ?

Is there a step-by-step tutorial on how to create plugins for f2c?

Thanks!

N
F2C webmaster Accepted Answer Pending Moderation
Maybe this will help: http://documentation.form2content.com/f2c-extensions/joomla-plugins/151-create-your-own-form2content-plugin

But remember, you can also programme in your template: https://www.smarty.net/docsv2/en/language.function.php

This might be an easier option to create what you are looking for.
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Nicolas Accepted Answer Pending Moderation
Thank you, will look into this!
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.