There is a View of latest news title linked to the node page and I need to display them like this Effect.
I've trying to do it by creating a new template file for my views named:
views-view-list--latest-news--block.tpl.php
and this is the code I was trying to set to work:
<?php print $wrapper_prefix; ?>
<?php if (!empty($title)) : ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php print $list_type_prefix; ?>
<div class="type-wrap">
<span id="typed" style="white-space:pre;"></span> //this is where it shoul be typed...
</div>
<?php print $list_type_suffix; ?>
<?php print $wrapper_suffix; ?>
<?php
$setOfTitles = "";
foreach($rows as $id=>$row)
$setoftitles.="'".$row."'".",";
$setoftitles = rtrim($setoftitles , ','); // to remove the last `,`
print_r ($setoftitles); // and it says I have all of you node titles
?>
<?php print_r($setOfTitles); ?>
<script type="text/javascript">
var stitles = "<?php $setoftitles;?>"; </script>
<script type="text/javascript">
alert(stitles); //but its alerts is empty (means variable is not passed to js)
$(function(){
;
$("#typed").typed({
strings: [stitles],
typeSpeed: 30,
backDelay: 500,
loop: false,
contentType: 'html', // or text
// defaults to false for infinite loop
loopCount: false,
callback: function(){ foo(); },
resetCallback: function() { newTyped(); }
});
$(".reset").click(function(){
$("#typed").typed('reset');
});
});
function newTyped(){ /* A new typed object */ }
function foo(){ console.log("Callback"); }
</script>
but it is not a true answer!! because my alert in js is empty and means I couldn't pass variable form php to js. Where is the problem? and how can I solve it? or is there a better way to do it?