Template for MIGX MODx - modx

I have some PHP foreach that i have moved to MIGX, now can somebody know how to make template for MIGX, here is my PHP
<?php
$i = 0;
$y = 0;
$active = 'active';
echo '<ol class="carousel-indicators">';
foreach(glob($dir) as $file) {
if ($i < 1) {
echo '<li data-target="#myCarousel" data-slide-to="' . $i . '" class="active"></li>';
$i = $i + 1;
}
else {
echo '
<li data-target="#myCarousel" data-slide-to="' . $i . '"></li>';
$i = $i + 1;
}
}
echo '</ol>';
echo '<div class="carousel-inner">';
foreach(glob($dir) as $file) {
$y = $y + 1;
if ($y == 1) {
echo '
<div class="' . $active . ' item">
<img class="img_book" src="' . $file . '" alt="">
</div>
';
}
else {
$active = 'not-active';
echo '
<div class="' . $active . ' item">
<img class="img_book" src="' . $file . '" alt="">
</div>
';
}
}
echo '</div>';

The MIGX Extra comes with a Snippet getImageList that will parse the values in the MIGX TV and return them based on a Chunk template that you specify.
For example, you could put this snippet call in your Template:
<div class="carousel-inner">
[[getImageList?
&tvname=`myMIGXtv`
&tpl=`myTplChunk`
]]
</div>
The snippet would return the values stored in the MIGX TV named myMIGXtv, in the currently requested Resource, and format the output based on the tpl Chunk names myTplChunk. The content of myTplChunk would be something like:
<div class="[[+idx:is=`1`:then=`active`:else=``]] item">
<img class="img_book" src="[[+file]]" alt="[[+another_migx_field]]">
</div>
The syntax of calling the [[+idx]] placeholder with a : after the tag name, invokes the MODX output modifier class, which supports conditionals.
Here are some reference materials for the methods described above:
Documentation for MIGX getImageList
Documentation for MODX
Output Modifiers
The right way and wrong way to use conditional
MODX Output Modifiers

Related

select option from Bot response

I am new to API.ai. I want to functionality such that when a Bot response says something to select from various options, user will select one of the options.
e.g.,
If Bot response says 'Which type of websites do you want to build?'
Select one of the given options.
1) Static
2) Dynamic
3) One page.
I have gone though various helps from the documentation , but I do not know how to set this up.
Please help.
This is your answer :
$arr = [];
if ($var == "Which type of websites do you want to build?") {
$arr[] = "Static";
$arr[] = "Dynamic";
$arr[] = "One page";
} else {
$arr[] = "option1";
$arr[] = "option1";
$arr[] = "option1";
}
Html Code:
<select name="website">
<?php
foreach ($arr as $key => $value) {
?>
<option value="<?php echo $value ?>"><?php echo $value; ?></option>
<?php
}
?>
</select>
Let me know if you require more details.

Mozilla doesn't displays datepicker input

I am using this function to create a date input
public static function date($name, $value = null, $options = array()) {
$input = '<input type="date" name="' . $name . '" value="' . $value . '"';
foreach ($options as $key => $value) {
$input .= ' ' . $key . '="' . $value . '"';
}
$input .= '>';
return $input;
}
And then in my view
<div class="form-group">
{{ Form::label('sgs', Lang::get('messages.sgs').'*', array('class'=>'control-label col-lg-4')) }}
<div class="col-lg-8">
{{ Helpers\Helper::date('sgs', isset($v->sgs) ? $v->sgs : '' , array(
'class' => 'form-control'))
}}
</div>
</div>
In Google Chrome it works, and displays datepicker which is displayed by clicking at a arrow, the problem is with Mozilla Firefox which doesnt displays datepicker and just displays it as a simple input field. Why is happening this
The HTML5 DatePicker is not supported in Firefox. Therefore, you will need to use some custom DatePicker plugin. You can see this for the compatibility reference:
http://caniuse.com/#feat=input-datetime

Masonry Infinite Scroll with Database and Anchor Tag that links to the current document

I am new to PHP, Javascript and HTML. So maybe I'm missing something obvious but, I can't for the life of me figure out what is wrong with my code. I am trying to use Paul Irish's Infinite Scroll with a PHP file that has an anchor point that links back to itself with different GET values. The problem is that Anything I do gives me this error:
Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag.
I am at my wits end and desperately need someones help because I need this done by January 20th. It's going to be a birthday gift for someone I know.
Here is my code:
index.php (Code Snippet)
<div id="content-container" class="container-fluid" style="padding:0px;overflow:hidden;">
<div class="row-fluid full">
<div class="span12 full" style="overflow:scroll;position:relative;">
<div id="media-palette">
<?php
include('content.php');
?>
</div>
</div>
</div>
</div>
script.js (Code Snippet)
$("#media-palette").infinitescroll({
navSelector:"#next",
nextSelector:"#media-palette a#next:last",
itemSelector:".media-content",
bufferPx:50,
debug: true,
}, function(newElements) {
$("#media-palette").masonry('append', newElements,true);
});
content.php
(It is worth noting that the images found in this file are for testing purposes and the final PHP file will load images from a database.)
<?php
require('dbconnect.php');
$startIndex = $_GET['start'];
$endIndex = $_GET['end'];
$nextStartIndex = $endIndex-1;
$nextEndIndex = $endIndex-10;
?>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
$files = scandir("images");
if ($files) {
$length = count($files);
static $allowedExts = array("jpg", "jpeg", "gif", "png");
for ($i = 0; $i < $length; $i++) {
$extension = end(explode(".", $files[$i]));
$extension = strtolower($extension);
if (in_array($extension,$allowedExts)) {
$rand = rand(0,10);
if (!$rand) echo "<img class='media-content medium' src='images/".$files[$i]."'/>";
else echo "<img class='media-content small' src='images/".$files[$i]."'/>";
}
}
}
echo '<a id="next" href="content.php?start='.$nextStartIndex.'&end='.$nextEndIndex.'"></a>';
?>
</body>

how to show different effects in nivoslider dynamically

i am using nivoslider and have 4 different slides and for each slide i want different effect as slideInLeft,fade,fold and sliceUpDown for each different one. my slider is running well,it's just i needed different sliding effect for each slides.i am using codeigniter. any help/suggestions are welcome.thanks
<img src="uploaded_files/banner/<?php echo $banner->file ?>" data-thumb="uploaded_files/banner/<?php echo $banner->file ?>" alt="" data-transition="slideInLeft"/>
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
it is simple.i just to have to add some conditions as follows.
$i = 1;
if($i=='1') $transition = 'slideInLeft';
elseif($i=='2') $transition='fade';
elseif($i=='3') $transition='fold';
else $transition = 'sliceUpDown';
?>
<img src="uploaded_files/banner/<?php echo $banner->file ?>" data-thumb="uploaded_files/banner/<?php echo $banner->file ?>" alt="" data-transition="<?php echo $transition?>"/>
$i++;
it worked but if someone has some better idea than this one,please do share.

Concrete 5 Theme: for Menu navigation

i am new to concrete 5, i search alot for theming of Menu (i.e: sub menu's) navigation with image icon and description but not found any related material. i have the following Html:
<div class="menu">
<ul>
<li><span>Hem</span></li>
<ul>
<li><span>New</span><img href="images/first.jpg" /><span class='short-description'>some description</span></li>
<li><span>Nice</span></li>
</ul>
<li><span>Om oss</span></li>
<ul>
<li><span>Om Shine</span><img href="images/second.jpg" /><span class='short-description'>some description</span></li>
<li><span>Uom</span></li>
<li><span>Opasd</span><img href="images/third.jpg" /><span class='short-description'>some description</span></li>
<li><span>Hem</span></li>
</ul>
<li><span>Tjänster</span></li>
<li><span>Referenser</span></li>
<li><span> Kontakt</span></li>
</ul>
</div>
So how i can theme for this in concrete 5. or use like.
<div id="headerNav">
<?php
$a = new Area('Header Nav');
$a->display($c);
?>
</div>
Any idea about it, that how to theme for this in concrete 5 for sub menus with description and image icon.... Thanx.
Open file concrete\concrete\blocks\autonav, and changed line
if ($c->getCollectionID() == $_c->getCollectionID()) {
echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
}
Apply your active class in " tag like
if ($c->getCollectionID() == $_c->getCollectionID()) {
echo('<li class="nav-selected nav-path-selected"><a class="active" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
}

Resources