First off all let me explain what I am trying to do.
Within modx I have created a template called: product.
The product template has several template variables assigned to it such as; manufacturer, manufacturer name, msrp, etc.
Than within my base template I have replaced the [[*content]] variable with a call to a custom snippet called: yield.
Now I would like the yield snippet to nest the content of any given document assigned to the template product.
I would like to do this so that I can use a single layout for every document type, rather than needing separate templates with repetitive snippets, chunks, etc for common items such navs, footers, headers, rails, banners, etc.
So I’m trying figure out if within my yield snippet if its possible to execute another request and embed the content within the base content.
I started looking through the modX API briefly, even dumping the modx object methods, but nothing stuck out.
I essentially want to use templates as a way to theme different documents.
I would like to be able to place the output of ProductTemplate inside my BaseTemplate. The BaseTemplate looks like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Main Layout</title>
</head>
<body>
[[*content]]
</body>
</html>
So I would like to find a way to always wrap the requested document in the above template. This way I can restrict the TVs to only the template of the entity that they correspond. Otherwise, I would need to make the product TVs available to the base template, which I don’t want to do. The product TVs should only be accessible by the product template.
Really, I’m just trying to always dump the requested content in a wrapper. It doesn’t seem like this should be so tricky…
Well that won’t work. The goal is to limit the scope of the product TVs to only the product template, yet still wrap it in a master template were those TVs are not accessible.
Another question though has come up.
I have now changed the manufacturer_name TV to manufacturers_id. The manufacturers_id TV stored a foreign key reference to the manufacturer the product belongs to. This is done by using a select binding on the input definition for the TV using a drop down. However, I am now trying to figure out the best way to display the manufacturer name in the product template. This is the current product template.
1. User Internal Key: [[+userId:userinfo=`internalKey`]]<br />
2. User name: [[+userId:userinfo=`username`]]<br />
3. Full Name:[[+userId:userinfo=`fullname`]]<br />
4. Role: [[+userId:userinfo=`role`]]<br />
5. E-mail: [[+userId:userinfo=`email`]]<br />
6. Phone: [[+userId:userinfo=`phone`]]<br />
7. Mobile Phone: [[+userId:userinfo=`mobilephone`]]<br />
8. Fax: [[+userId:userinfo=`fax`]]<br />
9. Date of birth: [[+userId:userinfo=`dob`:date=`%Y-%m-%d`]]<br />
10. Gender[[+userId:userinfo=`gender`]]<br />
11. Country: [[+userId:userinfo=`country`]]<br />
12. State: [[+userId:userinfo=`state`]]<br />
13. Zip Code: [[+userId:userinfo=`zip`]]<br />
14. Photo: [[+userId:userinfo=`photo`]]<br />
15. Comment: [[+userId:userinfo=`comment`]]<br />
16. Password: [[+userId:userinfo=`password`]]<br />
17. Cache Password: [[+userId:userinfo=`cachepwd`]]<br />
18. Last Login: [[+userId:userinfo=`lastlogin`:date=`%Y-%m-%d`]]<br />
19. The Login:[[+userId:userinfo=`thislogin`:date=`%Y-%m-%d`]]<br />
20. Number of Logins: [[+userId:userinfo=`logincount`]]
I was thinking it would be possible to do the same thing with a document, given its ID, am I incorrect? I essentially need the modifier to select the document info and display the page title – the manufacturers name. I tried documentinfo, sitecontentinfo, contentinfo, none of them seem to yield the expected results, just the manufacturers_id. Any ideas?
This doesn’t seem like the most optimized solution, considering it probably results in a query. However, I created a snippet called documentinfo, that accepts the doc id and a field. So pretty much it does the same thing as userinfo, but for documents. That seems to yield the intended results.
I was thinking it would be nice if I could create a TV named manufacturer_name. However, have it hidden to form input. Instead have it populate automatically and feed to the template from the current document data. Bot sure if that is possible though.