MODX Revolution get value of MIGX TV from another resource - modx-revolution

I have a resource that gets data from a MIGX TV in the following chunk
<ul id="testimonialsSlider">
<li>
<div>
<i class="fa fa-quote-left"></i><p>[[+text]]</p><i class="fa fa-quote-right"></i>
</div>
<p>[[+name]]</p>
<p>[[+source]]</p>
</li>
</ul>
and I want to use that data on yet another resource. How do I get those three TVs? Via getResources?

The Snippet that comes with the MIGX Extra, called "getImageList", accepts a property that tells it which MODX Resource from which to query the MIGX TV. An example of such a snippet call might be:
[[getImageList?
&tvname=`myMIGXtv`
&tpl=`testimonialsSliderItem`
&docid=`5`
]]
That would get the content of the TV named myMIGXtv from the MODX Resource with ID of 5, and format the output using the Chunk named testimonialsSliderItem.
Assuming your MIGX TV is configured with fields that have the keys: text, name, and source, AND the Resource ID 5 has the values you want, in those fields in the MIGX TV named myMIGXtv, AND your example Chunk is named testimonialsSliderItem...then the example above should work verbatim.

Related

Rails href with hash value not updating url

I'm using Materialize Tabs and have everything working fine, except the fact that my URL doesn't update when I click a tab link. I have the following two links:
<ul id="db-tabs" class="tabs">
<li class="tab col s3"><a class="tab-text active" href="#activegroups">Active Groups</a></li>
<li class="tab col s3"><a class="tab-text" href="#submittedgroups">Submitted Groups</a></li>
</ul>
Yet when I click one of these links, the URL remains unchanged. I would have expected the URL to change to something like /admin#submittedgroups, yet is just remains /admin.
If I manually enter the url /admin#submittedgroups, i'll get taken to the correct tab but otherwise the URL never changes.
Any ideas of what i'm doing wrong?
The javascript library you're using is preventing the default action, including the default browser navigation. You'll need to manually update the URL with javascript if this is your desired behavior, or use a different library.

Should I store markup in resource files?

I read this article: Using HTML inside resource files but didn't find a satisfactory answer.
Basically, if I wanted to store:
<h2>Some heading</h2>
<p>An introduction for a series of steps</p>
<ol>
<li>Do x and y</li>
<li>Do y and z</li>
<li>Final step</li>
</ol>
would I put the whole thing into a resource entry or would I create a view that retrieved these values and marked them up?
<h2>#MyPage.Header</h2>
<p>#MyPage.Intro</p>
<ol>
<li>#MyPage.Step1</li>
<li>#MyPage.Step2</li>
<li>#MyPage.Step3</li>
</ol>
and then, if the final step contained markup like:
Make sure to read our disclaimers before continuing...
then would I have to write?
<li>
#MyPage.Step3MakeSure
#MyPage.Step3Read
#MyPage.Step3Before
</li>
the problem with embedding markup in the resource files is that now a translator needs to know to not touch the markup and if they do you're in trouble... but I can't think of a good structure?
Personally, I would use a templating for javascript such as Mustache or UnderScoreJs... then just load up the data based on a call to a controller action, see demo here for Mustache.
Mustache Demo

Adding element ID to navigation items in Grails Platform Core Navigation API

Is it possible to add HTML attributes such as id or class to each menu item generated by the Grails Platform Core Navigation API?
Perhaps something similar to:
home(controller: 'home', action:'index', titleText:'Home', elementId: 'navHome')
I am writing some functional tests which use the generated links. However, the link text (and possibly the URLs) might change. Using an ID would make the tests easier to maintain.
The Navigation API provides the ability to add additional values via the data map and custom menu item rendering.
Example:
Step 1
Add the data map to the menu item definition in config/AppNavigation.groovy.
home(controller: 'home', action:'index', titleText:'Home', data: [elementId: 'navHome'])
Step 2
Reference the data map using item.data.* in the GSP file.
<nav:primary scope="some scope" custom="true">
<li>
<p:callTag
tag="g:link"
attrs="${linkArgs + [class:active ? 'active' : ''] + [elementId:item.data.elementId]}"
><nav:title item="${item}"/></p:callTag>
</li>
</nav:primary>
This will result in the following HTML:
<ul class="nav primary">
<li>
Home
</li>
</ul>
See the nav:menu tag documentation in the Navigation API documentation for more information.

mvc+jqm actionlink html text issue

I'm just starting out with MVC, and I'm trying to build a sample, proof of concept page for mvc interaction with jquery-mobile. I've searched for an answer on this, but I don't think I know enough yet to formulate proper queries.
On my view, I am trying to generate output that functions like this (sampled from the jqm demo site) :
<ul data-role="listview" data-inset="true">
<li><a href="index.html">
<h3>Stephen Weber</h3>
<p><strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p>
<p>Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the jQuery team.</p>
<p class="ui-li-aside"><strong>6:24</strong>PM</p>
</a></li>
<li><a href="index.html">
<h3>jQuery Team</h3>
<p><strong>Boston Conference Planning</strong></p>
<p>In preparation for the upcoming conference in Boston, we need to start gathering a list of sponsors and speakers.</p>
<p class="ui-li-aside"><strong>9:18</strong>AM</p>
</a></li>
</ul>
So, I'm working it like this :
#foreach (var item in Model) {
<li>
#Html.ActionLink( LargeExpandedMultiContentText, "Edit", new { id = item.SysID })
</li>
}
My question, which I don't know a simple way of asking, is, how, in MVC terms, do I fill the variable, so that the href generated by ActionLink() matches the style I've sampled from the jqm website?
I've tried this, and while it almost works, I'm sure its not the 'right' way, especially when I get to a spot of pulling "Steven Weber" and other strings out the the item/Model...plus it encodes the text, but I'm sure there's a way to deal with that easy enough.
#foreach (var item in Model) {
<li>
#{ String txt = "<h3>Stephen Weber</h3><p><strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p><p>Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the jQuery team.</p> <p class=\"ui-li-aside\"><strong>6:24</strong>PM</p>";
}
#Html.ActionLink( txt, "Edit", new { id = item.SysID })
</li>
}
Thanks, I appreciate your help
Brian
I'm not sure it's possible to use Html.ActionLink to build such a complex action link. That said, the Html Helpers are just supposed to be helper functions to make your life easier by giving you shortcuts to render HTML in ways commonly required. You don't need to use them. In this case, I think instead you should use a normal html tag, and Url.Action to create the correct URL.
If you wanted to include this information within an enumerable model I'd probably do something like:
#foreach (var item in Model) {
<li><a href="#Url.Action(item.Action)">
<h3>#item.Name</h3>
<p><strong>#item.Title</strong></p>
<p>#item.Message</p>
<p class="ui-li-aside"><strong>#item.Time</strong>#item.TimePeriod</p>
</a></li>
}
Note: the function you were looking for to display contents without encoding them is #Html.Raw
In answer to my other 'half question' I found this resource...
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
I believe the "razor delegate" item there at the bottom would fit the need I had.
#{
Func<dynamic, object> b =
#<strong>#item</strong>;
}
#b("Bold this")

Smarty - same template different content

What is the strategy in smarty for using different variables each time a template is included in another template?
Here is what I mean.
I have a smarty template that creates a simple navigation list.
<ul class='linkList'>
<li>
<h3>{$title}</h3>
<ul>
{foreach $links as $d}
<li><a title='{$d...}' href='{$d....}'>{$d.text}</a></li>
{/foreach}
</ul>
</li>
</ul>
I want to include it a number of times in my main template and each time pass it different values. Im not sure what strategy to use to do this.
If I assign variables in my php file like this
$smarty->assign('links',array(.....);
$smarty->assign('title','My first link list');
$smarty->assign('links',array(different values);
$smarty->assign('title','My second link list');
and then include the template twice i will just get the same list twice with the second lot of values.
The {include} tag allows you to pass variables in the call:
{include 'linklist.tpl' title="Sample Links 1" links=$link_array1}
{include 'linklist.tpl' title="Sample Links 2" links=$link_array2}
Otherwise, I'm pretty sure you can use either {assign} or the short form of assign ({$var=value}) before including the template.

Resources