MODx - How to create MIGX inside another MIGX? - modx

Good day!
To my regret I can not create migx inside another migx.
Below is the code that I use.
mainTV (slider):
[
{"caption":"Info", "fields": [
{"field":"slider_title","caption":"Header row","inputTV":"slider_title_row"},
{"field":"image","caption":"Image","inputTV":"image_helper"}
]}
]
subTV (slider_title_row):
[
{"caption":"Header row", "fields": [
{"field":"title_row","caption":"Header row","inputTVtype":"text"}
]}
]
main call:
<div class="main-carousel">
[[!getImageList? &tvname=`slider` &tpl=`Slider_title.tpl`]]
</div>
chank Slider_title.tpl:
<div class="main-carousel__item carousel-item" style="background-image:url([[+image]]);">
<div class="container">
<div class="carousel-item__description">
<h2>[[!getImageList?
&tpl=`Slider_title_row.tpl`
&value=`[[+slider_title]]`
]]
</h2>
</div>
</div>
</div>
chank Slider_title_row.tpl:
<div>[[+title_row]]</div>
I can not understand what I'm doing wrong??
Thank you in advance.

From what I can see, the issue seems to be from the use of &tvname on the outer migx call.
Swap this to be similar to what you have for the inner one, and it should work just fine.
<div class="main-carousel">
[[!getImageList? &value=`[[*slider]]` &tpl=`Slider_title.tpl`]]
</div>

Related

Pass prop in img src in template

In my component, I am trying to pass a dynamic string prop to the image src
<template>
<div class="flex flex-column col-12 md:col-6 xl:col-4 surface-card p-4 border-round border-bg text-left">
<h2>{{ title }}</h2>
<a :href="url">
<img :src="require(`../assets/images/${image}.png`)" class="portfolio-img" alt="" />
</a>
<div class="font-medium text-500 mb-3">
<p>{{ text }}</p>
</div>
<a class="p-button p-component p-button-raised p-ripple external-link" :href="url" target="_blank">Visit</a>
</div>
</template>
And in my View I am trying to create a for loop to display all of the properties. The data is coming from a very simple json file.
<Card v-for="item in portfolioData.portfolio"
:title="item.title"
:image="item.img"
:url="item.url"
:text="item.text">
</Card>
{
"portfolio":
[
{
"title": "test",
"url": "test",
"img": "AICN-Group",
"text": "test test test"
}
]
}
I get issues with Webpack when trying to do this
error: Cannot find module './undefined.png'
at webpackContextResolve (eval at ./src/assets/images sync recursive ^\.\/.*\.png$
I don't understand this at all so could do with some help understanding it as well as a solution if possible. I've tried other solutions on SO but they don't seem to work.
Thanks.

#each inside another #each that is not a part of the first one handlebars

I got a problem with displaying values inside "main" loop
my code looks like this:
{{# each movies}}
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<!--<img src="..." alt="...">-->
<div class="caption">
<h3>{{this.title}}</h3>
<p>Rating :
{{#each ../ratings}}
{{this}}
{{/each}}
</p>
<p>Genre: <b>{{this.genre}}</b></p>
<p>{{this.description}}</p>
<p>Modify Delete</p>
</div>
</div>
</div>
{{/each}}
And the problem is that I get all three values of "ratings" list inside the same block, but I want to get them separately one per each of movies. Any suggestions? Thank you in advance.
I needed to change my model and include rating field to it. So I didn't need the second each loop at all.

react pagination for sections

Im using NodeJS with React and I have a problem. I didnt find a npm module or a code that allowed me to create a pagination for a list of results.
I have a variable called "jobs", that contains a list of job ads.
In my render function I call:
{this.state.jobs.map(this.renderClass)}
that map every job with a function.
This function is renderClass, that contains the render of:
<section key={c.id} className="panel panel-featured-left panel-featured-primary">
<Link to={'/job/'+c.id}>
<div className="panel-body">
<div className="widget-summary">
<div className="widget-summary-col widget-summary-col-icon">
<div className="summary-icon">
<img src={image} className="img-responsive" />
</div>
</div>
<div className="widget-summary-col">
<div className="summary">
<h4 className="title">{c.company}</h4>
<div className="info">
<strong className="amount"></strong><br/>
<p><i className="fa fa-map-marker"></i> {c.location}</p>
<p><i className="fa fa-suitcase"></i> {c.position}</p>
</div>
</div>
<div className="summary-footer">
<a className="text-muted text-uppercase"><i className="fa fa-calendar"></i> {day}/{month}/{year}</a>
</div>
</div>
</div>
</div>
</Link>
</section>
In this way I have a huge list of jobs, but I would a paging.
How can I do this?
Thanks
I would save the page in a state,
and do something like that (say each page has 10 jobs ) -
{this.state.jobs.slice(this.state.page * 10, this.state.page * 10 + 10)
.map(this.renderClass)}
I suggest your need to build a component for handling pagination. Some thing like that:
<Pagiantion
listLenght = {111}
selectedPage = {1}
itemPerPage = {10}
....
/>
I found the best component handling it, react-pagination-custom.
It allow you custom everything (number buttons, wrap container, spread,..). Its document is well, demo is also clear.

angularjs data binding not working on string variable?

I have 2 versions of my code, one is not working and the other it is.
My question is "why the not working one is not working?"
here is the JSfiddle http://jsfiddle.net/fhjF7/
The not working version:
Controller:
function Ctrl($scope) {
$scope.username = "username";
$scope.users = [ "Matteo", "Marco", "Michele" ];
};
HTML:
<h1> Not working example</h1>
<div ng-controller="Ctrl">
<div ng-repeat="user in users">
<input type="radio" ng-model="username" name="usern" ng-value="user" />
<strong>{{user}}</strong>
</div>
<div>selected: {{username}}</div>
</div>
and here is the working one, which is almost identical but replacing the string variable with an object:
Controller:
function usersCtrl($scope) {
$scope.names = {username: "username"};
$scope.users = [ "Matteo", "Marco", "Michele" ];
};
HTML:
<h1> Working example</h1>
<div ng-controller="usersCtrl">
<div ng-repeat="user in users">
<input type="radio" ng-model="names.username" name="username" ng-value="user" />
<strong>{{user}}</strong>
</div>
<div>selected: {{names.username}}</div>
</div>
It is because of the way javascript manages function parameters.
The easy way to understand it is that String, Number, and Boolean parameters are always sent byValue, while Objects and Functions are always sent byRef, that is why when you use the dot inside an ng-model it means you are doing a reference to an object which will propagate, while if you don't use a dot inside the ng-model, you are referencing a String, Number or Boolean which is actually a copy of the real variable.
More information here https://egghead.io/lessons/angularjs-the-dot and https://github.com/angular/angular.js/wiki/Understanding-Scopes
Ng-repeats create their own isolate scopes, so that's why the string is not being preserved as it's not pass by reference. If you want to update the model use
<input type="radio" ng-model="$parent.username" name="usern" ng-value="user" />
$parent gives you access to the parents scope which is outside the ng-repeat and should be the one you want.
The answer for your not working code : http://jsfiddle.net/ashuslove/fhjF7/30/
HTML :
<h1> Not working example</h1>
<div ng-controller="Ctrl">
<div ng-repeat="user in users">
<input type="radio" ng-model="names.usern" name="usern" ng-value="user" />
<strong>{{user}}</strong>
</div>
<div>selected: {{names.usern}}</div> //Changed line here
</div>
The function :
function Ctrl($scope) {
$scope.names = {usern: "usern"}; //Also need to change this
$scope.users = [ "Matteo", "Marco", "Michele" ];
};

expressionengine search {auto_path} wrong entry

I'm having trouble configuring the search results, linking to that specific result.
I've set the channel search preferences so that {auto_path} links to the relevant template group and template and I have had no trouble with this whatsoever.
The only trouble I am having is that when you click on the title of the result, when you are sent to the page that displays the specific entry, rather than display that specific entry, it shows you the most recent entry posted on that channel.
I’ve also noticed that when you click the result, the url which should display as this:
http://www.mywebsite.com/ee_site/index.php?/template_group/template/entry
actually renders as this:
http://www.mywebsite.com/ee_site/index.php?/template_group/template/?/entry
Whats up with the extra ‘?/’ inbetween the template and the entry?
Here is the code for the results page:
{embed="embeds/html-head" page_title="Blog"}
<body>
<div id="container">
{embed="embeds/header"}
{embed="embeds/navigation"}
<div id="hero">
<div id="heading">
<div id="title">
<h2>{exp:search:total_results} RESULT(S) FOR {exp:search:keywords}</h2>
</div>
</div>
<div id="blog">
<ul>
{exp:search:search_results}
<div class="blog">
<li class="search_results"><strong>{title}</strong> from <em>{channel}</em>
<br/>
{excerpt}
<br/>
</li>
</div>
{/exp:search:search_results}
</ul>
</div>
</div>
{embed="embeds/footer"}
</div>
</body>
</html>
and here is the code for a gallery entry
{embed="embeds/html-head"}
<body>
<div id="container">
{embed="embeds/header"}
{embed="embeds/navigation"}
<div id="hero">
<div id="heading">
{exp:channel:entries channel="gallery" limit="1" disable="pagination"}
<div id="title">
<h2>Gallery</h2>
</div>
<div id="story_title">
<h2>{title}</h2>
</div>
</div>
<div id="video_main">
<img class="image" src="{image}" alt="{title}">
</div>
<div id="featured" class="main">
<p>{info}</p>
<p class="url">{source}</p>
</div>
{/exp:channel:entries}
{embed="embeds/footer"}
</div>
</body>
</html>
On a category page, when you click an entry and are taken to this page, it displays the specific entry clicked on, so I know that there is nothing wrong with that aspect.
Any suggestions/solutions would be much appreciated, i'm sure it's something minor that i'm just not spotting!

Resources