I’ll probably get an oscar soon for asking all these questions but... there are a couple of more obstacles throughout my project. One of them is the relationship between different posts. I have a couple of products that are displayed, each with their own page. These products all have one or more certificate(s) associated with them. The certificates and the products are stored in entirely different categories, the question is how does one tie them together in a good, easily editable way? WordPress has tags, Drupal has all sorts of associable types but with ModX - what should I use?
Tags.
Create a new TV, attach it to the template and use this TV as tags. eg. tag1,tag2
OR you can have preset tags: eg. a dropdown list of predefined tags in TV input options.
I would say your later suggestion sounds very efficient, if I can fetch all current ceritificates. I’ll look into it.
Try @SELECT binding for TV input.
Solved:
1. Create a TV with a Listbox (Multi-Select).
2. Apply "@SELECT pagetitle,id FROM modx_site_content WHERE parent = X" in the Input Option Values field (X is your Certificates resource).
3. Apply a Widget with a Delimited List using commas.
4. In a Template, use Ditto and call the selected associations by using "[!Ditto? &documents=`[*related-certificates*]` &tpl=`certificate-list-item` &noResults=`<p>No certificates related to this product.</p>`!]"
One thing I don’t understand is how ModX "knows" that I want to display Pagetitle in the listbox (the user would never know which ID belonged to what certificate, obviously) then correctly uses the ID for finding the document in the Ditto output, thereby (with the aid of the "certificate-list-item" template) showing the correct image and link.
-
☆ A M B ☆
- 24,524 Posts
the input processor sees that it’s been handed a resource, so it must be a recordset from a database query. It loops through it just as you would after making a select query, and creates the array necessary for building the input.
else if(is_resource($v)) {
while ($cols = mysql_fetch_row($v)) $a[] = $cols;
}
Experiment a bit... see what would happen if you had @SELECT id,pagetitle ... instead.