Hello all,
When rendering a dynamic celebrity page (
http://famous-relationships.topsynergy.com/Angelina_Jolie/"" target="_blank" rel="nofollow">see existing example), the celebrity’s basic information is retrieved from a database table and used dozens of times on each and every page that belongs to that celebrity.
Sample repetitive data segments: uniqueID, name, gender, birth date, photo, and URL string (for file names and URLs).
Sample use: meta-tags, document content, parsing and manipulating database query results, forms, PHP scripts, and structuring URLs and anchor text in navigation links.
So I wrote a snippet that retrieves all these data segments for current celebrity (based on friendly URL) and discovered how easy it is to embed the values where needed in the document via:
1. Conditional output:
[[getCelebParams? &CelebID=`1` &ParamName=`FullName`]]
or;
2. Sending the output to a chunk from within the snippet:
$output.=$modx->parseChunk('CelebParams', $params, '[+', '+]');
My challenges are three:
1. None of this methods works in the template itself. It seems that the snippet’s variables are private and hidden to the template layer. Let’s say that I want to declare a "keywords" meta-tag with the celebrity FullName as the first keyword. How do I call for the value to be parsed in the template before it renders? I tried to play with different @Binding methods to call the snippet via TVs but failed miserably.
2. If I output each data segment via its dedicated chunk (Name, Date of Birth, He/She, Have/Had, etc.) according to what needs to be parsed in the content, I need to maintain many small and cumbersome chunks. However, if i call the snippet each time, I cause it to re-query the database and re-evaluate the PHP code for no particular need or reason.
3. To add some complexity - each celebrity will have on the new platform around 40 pages - all share these basic data segments. I believe that being able to cache this data once retrieved for a specific CelebID becomes almost mandatory.
In summary: can you help me please to see the big picture and to devise the right method to serve all the issues above?