MODX - Access TV's of resource fetched from a ResourceList and display with getImageList - modx

I'm trying to output template variables from resources input into a MIGX template variable, which references a template variable with an input type of 'Resource List'. Is this possible?
I've got a template variable(TV) in MODX which has an input type of "Resource List", this TV is called 'product_offer'. This resource list has a where clause which states that it can only contain products with a certain template ID.
I then have another TV which has an input type of MIGX. I use this TV to allow one of my resources to select a list of Resources in a template variable. The MIGX TV's form tab JSON is below. This TV is called 'offersList'.
[
{"caption":"Product", "fields": [
{"field":"Product","caption":"Product","inputTV":"product_offer"}
]}
]
In one of my chunks i'm using getImageList (snippet that comes with migx) to display the list of resources that I've input into the 'offers_list'. Code snippet below:
[[getImageList?
&tvname=`offersList`
&tpl=`StoreCategoryTpl-New`
]]
The chunk "StoreCategoryTpl-New" accesses the resources with this specific ID's template variables and displays a number of them. A cut-down snippet of the chunk is below.
<div class="product-container">
<img src="[[+tv.productImage:phpthumbof=`w=150&h=150&zc=1`]]" alt="Thumb of ([[!getResourceField? &id=`[[+product]]` &field=`pagetitle`]])" />
<h3>[[+pagetitle]]</h3>
</div>
Everywhere else in the site I have used this chunk to output the result of a getResources call, getResources of course can output Template Variables.
Can I access the template variables from the resources I've selected in my 'offersList' MIGX TV and output them in the chunk? I can't find any material for this on the forum or through Google searching.
If not, is the only solution to do this with getResources, and perhaps make a new TV which allows the user to enter in multiple Resource ID's as the value, then feed that into the getResources call (to only get those resources)?

I can only guess, but did you try and set the input TV Type like mentioned here?
https://docs.modx.com/extras/revo/migx/migx.backend-usage
I'd try and set the TV type.
Anyway, in the output chunk, you are trying to access the TVs like you would do with pdoTools or getResources before. As you would have to set "includeTVs", I guess it is not the default behaviour to read the TVs values from the database.
Yout Attempt to read them with getResourceField instead should work, also with the tv.productImage.
One last thing: you're using phpthumbof. Try pthumb instead, it is the new version and you can use it just like phpthumbof before.

Related

Shopware 5 accessing controller variables (Template Variables) on frontend

The technical term given in many articles for this is Template Variables. I am trying to understand how we can find the variable name given in the controller for a specific field of Shopware 5 front end (ex. Product Name)
For example, I can see the template variable for article name has been given as $sArticle.articleName. I found this when I checked the source code manually.
Let’s say I want to find the discount value given for particular product, How can I print this on my theme? What variable I should use and what is the easy way to find it.
I can assign values from back end for all the variables but my question is how I can access them on my theme file when I update my theme when it comes to technical development side.
Please Note: I am trying to understand the shopware5 technical side.
Using the {debug} function will usually give you a list of all assigned variables. This list should also include a variable $Controller which will give you a hint to the currently related Controller.
Unfortunately you are not able to identify where the assigned variables come from. Due to the event driven architecture of Shopware the variables can be assigned to the view after the request has been dispatched to the related Controller. This means that variables might he assigned through third party plugins as well as specific event listeners and store front decorators (in Shopware 5).
Kind regards!
If you want to use your variables inside the template you have to write a plugin and assign your controller-variables to the view.
Check out Globale Variablen im Template verwenden in the shopware documentation.
If you want to use see which variables are allready assigned, you can use {debug} in the template. Also {$sArticle|var_dump} is really helpful, if you want to debug a specific variable ($sArticle} in this example).
You have to known that shopware assigns the members of an object to the view.

SharePoint online people search display template showing skills managed property

I'm currently working on creating a custom display template for people search result page. I copied out of the box Item_Person.html search display template and modified it to display some more fields.
In the out of the box template also there is a managed property called skills but when I using it, its not returning any values associated with the user profile skills property (SPS-Skills).
As you can see its already mapped but Skill value always comes as empty. I want to retrieve and display inside the custom template.
Please help me if you have done something similar.
Check the following steps
Add meta data to ManagedPropertyMapping
2.Then inside the fuction get the value of metadata
<!--#_ var datacreated = $getItemValue(ctx, "Created");_#-->
3.Then palce the variable where you want <h2> _#= datacreated =#_ </h2>
Thats it publish the html hope its work

Sort articles by template variable

I have built a website (with MODX) where some products are managed and displayed via the articles addon. The products should have a custom ordering but I don't know how to use a template variable for that.
If I enter the name of the TV in the "Sort Field" field nothing is shown at all.
So is it somehow possible to use a TV there?
Or is there another way to achive a custom ordering (note that I need the summary and date fields, so I cant't abuse them for that)?
You can do this by using getResource package. Look at sorbyTV, sortdirTV, sortbyTVType parameters in manual:
http://rtfm.modx.com/extras/revo/getresources#getResources-SelectionProperties

How to show user's context resourcelist only

MODX Revolution 2.2.10-pl
Migx 2.6.8
I use this in a TV for my clients to be abble to choose a ressource :
{"field":"link1","caption":"Lien","inputTVtype":"resourcelist"}
The context of a user is defined with a user group context access.
I've tried to tick the checkbox of the user usergroup in the TV, but if I do that the user is not abble to see th TV anymore.
Problem is that mys client can see every ressources of every contexts. I need him to only be abble to see the resourcelist of their context. Is there a way to do that ?
You could make a TV with custom #eval options and use that for your migx field. See here for an example and description; http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/template-variables/bindings/eval-binding.
First change your TV to this, basically just swapping out "inputTVtype" to "inputTV"
{
"field":"link1",
"caption":"Lien",
"inputTV":"yourCustomTv"
}
Step two is to create a snippet that finds the resources you want, this requires you to have some knowledge of PHP. Basically you need to find the resources and loop them, outputting a string that looks like a regular list values string (resourceId==name||resourceId==name||...)
Step three is to create "yourCustomTv", and for the input options give it the #EVAL return $modx->runSnippet('yourSnippet');

get document by id in modx

Very simply I want to have multiple content regions on a single page. Note this is my first Modx site.
So far I have the home page and created child documents for the sub regions on the home page. All I want is to call them in the template.
For example there is a document with an id of 2, and I want the long title on the home page (id of 1).
Something like :
[[~2*longtitle]]
Unfortunately the above just returns the url to that sub document and not the longtitle of that document itself.
So far I've found no documentation on doing so. Does anyone know how to accomplish this?
You have 2 options, the hard way ~ the route you have chosen ;) and the easy way... which I will outline as well.
For what you are trying to do you are going to want to use either getResources http://rtfm.modx.com/display/ADDON/getResources which will allow you to loop over a collection of resources & extract the fields you need [in this case 'content'] or getresourceField http://rtfm.modx.com/display/ADDON/getResourceField which will allow you to specify a single resource & the field to extract, just call it multiple times in your template.
You might try:
[[getResources? &parents='[[*id]]' &tpl='myTpl' &includeContent='1']]
Should get all the child resources [up to default ~ 10] of the current resource, then you would create a template for get resources to loop over:
<h1>[[+longtitle]]</h1>
<p>[[+content]]</p>
notice the use of + instead of * for the resource fields
OR
the easy way, create template variables for your extra content areas, you can set them up as rich text areas as well. that way all your content for any given page is within the one resource ~ no need for you to create child resources to hold content for your header/footer/sidebar/etc
Either way will work, the TV method may use less overhead though.
you can use fastfield
[[#12.pagetitle]]
or in a call
[[#[[+id]].pagetitle]]
You can also grab all TVs of that resource, like
[[#12.myTv]]
see also: http://rtfm.modx.com/extras/revo/fastfield

Resources