We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt template has weird stuff in the header

The template does not render the variables I have pasted the weird stuff below I didn't paste the whole template the problem I believe is in the top Thanks anyone for help

<?php $v129018710851384329941iterator = $posts; $v129018710851384329941incr = 0; $v129018710851384329941loop = new stdClass(); $v129018710851384329941loop->length = count($v129018710851384329941iterator); $v129018710851384329941loop->index = 1; $v129018710851384329941loop->index0 = 1; $v129018710851384329941loop->revindex = $v129018710851384329941loop->length; $v129018710851384329941loop->revindex0 = $v129018710851384329941loop->length - 1; ?><?php foreach ($v129018710851384329941iterator as $post) { ?><?php $v129018710851384329941loop->first = ($v129018710851384329941incr == 0); $v129018710851384329941loop->index = $v129018710851384329941incr + 1; $v129018710851384329941loop->index0 = $v129018710851384329941incr; $v129018710851384329941loop->revindex = $v129018710851384329941loop->length - $v129018710851384329941incr; $v129018710851384329941loop->revindex0 = $v129018710851384329941loop->length - ($v129018710851384329941incr + 1); $v129018710851384329941loop->last = ($v129018710851384329941incr == ($v129018710851384329941loop->length - 1)); ?> <?php if (((($v129018710851384329941loop->index) % 2) != 0)) { ?> <div class="row"> <!-- content --> <div class="content clearfix">

            <!-- post list -->
            <div class="postlist">

                <div class="col-sm-6">
                    <!-- post item wide -->
                    <div class="post-item-wide">
                        <div class="inner">
                            <div class="post_title">
                                <h2><a href="#"><?php echo $post->title; ?></a></h2>
                            </div>
                            <div class="post-image">
                                <div class="badge badge-new"></div>
                                <img src="image?id=<?php echo $post->frontimage; ?>" alt="" />
                            </div>
                            <div class="post-meta-top">
                                Posted <span class="post-date"><?php echo $post->postdate; ?></span> 
                                by <span class="post-author"><?php echo $post->author; ?></span>
                            </div>
                            <div class="post-descr">
                                <p><?php echo $post->fronttext; ?></p>
                            </div>
                            <div class="post-meta-bot post-meta-links">
                                <div class="post-meta-likes">
                                <a href="Likes?id=<?php echo $post->id; ?>&type=post" class="post-like"><?php echo $post->likes; ?> &nbsplikes</a>
                                <a href="#" class="post-comm"><?php echo $post->comments; ?></a>


2.2k

Where is this showing up for you?

If it's in the compiled PHP file in the cache folder, then it's fine. It's just the template engine doing its thing.

If it's showing in the browser, does it only do it on this page, or are others behaving in the same way?



1.4k

It is only in this one template (the cache version) but the real issue why the template did not render is the $post-> if I change (which I did) to all $post[ ] everything works fine. Which has me very confused. I have over 40 templates and this is the only one giving me a problem Thanks very much for your help



2.2k

Is your $post an object or an array? $post->id will only work on objects, while $post["id"] will only work on arrays.

I've seen this kind of confusion before, regarding the difference between objects and arrays, usually when dealing with data coming out of ORMs or via JSON object conversion.

Either way is fine when you're just using it to transport data from a controller to a view, it's mainly a matter of preference for that purpose.