0

I have the site http://staging.cwtest.co.uk/entertainment/celebrity and i wrote the code for ajax loadmore in the button of the page. When click the load more button the ajax load the data that's is fine but i have use the plugin code inside the ajax which doesn't work properly. I have set the php parsing yes and output set the "output". So what is solution.

And ajax response code is like this

<?php
$i = "{segment_4}";
?>

<section class="subsection ajax">
    <div class="row">
        {exp:channel:entries channel="news" category="{segment_3}" limit="2" dynamic="off" offset="`<?php echo $i;?>`" orderby="date" sort="desc" disable="categories|category_fields"}
        <div class="col-md-4 col-sm-4">
            <div class="post-wrap">
                {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img src="{image}"></a></div>
                {/if}
                <div class="post-content">
                    <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a>
                    </h3>
                    <p>
                        {exp:word_limit total="15"}
                        {body}
                        {/exp:word_limit}
                    </p>
                </div>
            </div>
        </div>
        {/exp:channel:entries}
        <div class="col-md-4 col-sm-4">
            {exp:channel:entries channel="news" category="{segment_3}" limit="2" dynamic="off" offset="`<?=($i+2);?>`" orderby="date" sort="desc" disable="categories|category_fields"}
            <div class="wrap-content clearfix">
                <div class="post-wrap">
                    {if {count} == 1}
                        {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                        <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                        src="{image}"></a></div>
                        {/if}
                        <div class="post-content">
                            <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                            <p>{exp:word_limit total="15"}{body}{/exp:word_limit}</p>
                        </div>
                    {if:else}
                        <div class="post-content">
                            <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                            <p>{exp:word_limit total="15"}{body}{/exp:word_limit}</p>
                        </div>
                        {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                            <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                    src="{image}"></a></div>
                        {/if}
                    {/if}
                </div>
            </div>
            {/exp:channel:entries}
            <!-- /Wrap content -->
        </div>
        <!-- /Cols -->
    </div>
    <!-- /Row -->
    <div class="row margin-top-20">
        {exp:channel:entries channel="news" category="{segment_3}" limit="3" offset="`<?=($i+4);?>`" orderby="date" sort="desc" disable="categories|category_fields"}
        <div class="col-md-3 col-sm-3">
            <div class="post-wrap">
                {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                src="{image}"></a></div>
                {/if}
                <div class="post-content">
                    <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                    <p>
                        {exp:word_limit total="15"}
                        {body}
                        {/exp:word_limit}
                    </p>
                </div>
            </div>
        </div>
        {/exp:channel:entries}
        <!-- /Cols -->
        <div class="col-md-3 col-sm-3">
            <div class="advertisement">
                {ad_300x250_general_top}
            </div>
        </div>
        <!-- /Cols -->
    </div>
    <!-- /Row -->
    <div class="row margin-top-20">
        {exp:channel:entries channel="news" category="{segment_3}" limit="3" offset="`<?=($i+8);?>`" orderby="date" sort="desc" disable="categories|category_fields"}
        <div class="col-md-4 col-sm-4">
            <div class="wrap-content clearfix">
                <div class="post-wrap">
                    {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                    <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                    src="{image}"></a></div>
                    {/if}
                    <div class="post-content">
                        <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                        <p>
                            {exp:word_limit total="15"}
                            {body}
                            {/exp:word_limit}
                        </p>
                    </div>
                </div>
            </div>
            <!-- /Wrap content -->
        </div>
        {/exp:channel:entries}
    </div>
    <div class="row margin-top-20">
        <div class="col-md-9">
            {exp:channel:entries channel="news" category="{segment_3}" limit="4" offset="`<?=($i+11);?>`" orderby="date" sort="desc" disable="categories|category_fields"}
            <div class="col-md-3 col-sm-3">
                <div class="post-wrap">
                    {if '{exp:surgeree:modulo numerator="{count}" denominator="2"}' == 0}
                    <div class="post-content" id="{count}">
                        <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a>
                        </h3>
                        <p>
                            {exp:word_limit total="15"}
                            {body}
                            {/exp:word_limit}
                        </p>
                    </div>
                    {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                    <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img src="{image}"></a></div>
                    {/if}
                    {if:else}
                    {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                    <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img src="{image}"></a></div>
                    {/if}
                    <div class="post-content" id="{count}">
                        <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a>
                        </h3>
                        <p>
                            {exp:word_limit total="15"}
                            {body}
                            {/exp:word_limit}
                        </p>
                    </div>
                    {/if}
                </div>
            </div>
            {/exp:channel:entries}
            <!-- /Cols -->
        </div>
        <!-- /Cols 9 -->
        <div class="col-md-3 col-sm-3">
            <div class="add">
                {ad_300x100_general_top}
            </div>
            <div class="add">
                {ad_300x100_general_top}
            </div>
        </div>
        <!-- /Cols -->
    </div>
</section>
<?php exit; ?>
7
  • Please share your code, or an example. we will need to debug your code, the issue is not with the ajax (so a good way to test is to open the AJAX URL in a browser and study the output). It is likely you have a parse order issue within your AJAX endpoint. Also please confirm the template 'type'.
    – Blatant
    Jul 7, 2015 at 11:05
  • I have edit the code please check the question. Jul 7, 2015 at 11:10
  • And the output will be after clicking the more button in this link below please check staging.cwtest.co.uk/entertainment/celebrity Jul 7, 2015 at 11:20
  • Template type webpage Allow PHP yes, PHP Parsing stage to output. Jul 7, 2015 at 11:24
  • 1
    Can you clean up your question? It's annoying and hard to help you if you don't format your question decently.
    – jrothafer
    Jul 7, 2015 at 13:18

1 Answer 1

1

Ok, forget my previous answer, let me just correct this all for you!!!!

Copy paste this into your template :

<?php
    $i = "{segment_4}";
?>

<section class="subsection ajax">
    <div class="row">
        {exp:channel:entries channel="news" category="{segment_3}" limit="2" dynamic="off" offset="<?php echo $i ?>" orderby="date" sort="desc" disable="categories|category_fields"}
        <div class="col-md-4 col-sm-4">
            <div class="post-wrap">
                {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img src="{image}"></a></div>
                {/if}
                <div class="post-content">
                    <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a>
                    </h3>
                    <p>
                        {exp:word_limit total="15"}
                        {body}
                        {/exp:word_limit}
                    </p>
                </div>
            </div>
        </div>
        {/exp:channel:entries}
        <div class="col-md-4 col-sm-4">
            {exp:channel:entries channel="news" category="{segment_3}" limit="2" dynamic="off" offset="<?php echo ($i+2) ?>" orderby="date" sort="desc" disable="categories|category_fields"}
            <div class="wrap-content clearfix">
                <div class="post-wrap">
                    {if {count} == 1}
                        {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                        <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                        src="{image}"></a></div>
                        {/if}
                        <div class="post-content">
                            <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                            <p>{exp:word_limit total="15"}{body}{/exp:word_limit}</p>
                        </div>
                    {if:else}
                        <div class="post-content">
                            <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                            <p>{exp:word_limit total="15"}{body}{/exp:word_limit}</p>
                        </div>
                        {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                            <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                    src="{image}"></a></div>
                        {/if}
                    {/if}
                </div>
            </div>
            {/exp:channel:entries}
            <!-- /Wrap content -->
        </div>
        <!-- /Cols -->
    </div>
    <!-- /Row -->
    <div class="row margin-top-20">
        {exp:channel:entries channel="news" category="{segment_3}" limit="3" offset="<?php echo ($i+4) ?>" orderby="date" sort="desc" disable="categories|category_fields"}
        <div class="col-md-3 col-sm-3">
            <div class="post-wrap">
                {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                src="{image}"></a></div>
                {/if}
                <div class="post-content">
                    <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                    <p>
                        {exp:word_limit total="15"}
                        {body}
                        {/exp:word_limit}
                    </p>
                </div>
            </div>
        </div>
        {/exp:channel:entries}
        <!-- /Cols -->
        <div class="col-md-3 col-sm-3">
            <div class="advertisement">
                {ad_300x250_general_top}
            </div>
        </div>
        <!-- /Cols -->
    </div>
    <!-- /Row -->
    <div class="row margin-top-20">
        {exp:channel:entries channel="news" category="{segment_3}" limit="3" offset="<?php echo ($i+8) ?>" orderby="date" sort="desc" disable="categories|category_fields"}
        <div class="col-md-4 col-sm-4">
            <div class="wrap-content clearfix">
                <div class="post-wrap">
                    {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                    <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img
                    src="{image}"></a></div>
                    {/if}
                    <div class="post-content">
                        <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a></h3>
                        <p>
                            {exp:word_limit total="15"}
                            {body}
                            {/exp:word_limit}
                        </p>
                    </div>
                </div>
            </div>
            <!-- /Wrap content -->
        </div>
        {/exp:channel:entries}
    </div>
    <div class="row margin-top-20">
        <div class="col-md-9">
            {exp:channel:entries channel="news" category="{segment_3}" limit="4" offset="<?php echo ($i+11) ?>" orderby="date" sort="desc" disable="categories|category_fields"}
            <div class="col-md-3 col-sm-3">
                <div class="post-wrap">
                    {if '{exp:surgeree:modulo numerator="{count}" denominator="2"}' == 0}
                    <div class="post-content" id="{count}">
                        <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a>
                        </h3>
                        <p>
                            {exp:word_limit total="15"}
                            {body}
                            {/exp:word_limit}
                        </p>
                    </div>
                    {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                    <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img src="{image}"></a></div>
                    {/if}
                    {if:else}
                    {if "{image}"!="" && '{exp:bn_file_exists:check_file src="{image}"}'}
                    <div class="post-images"><a href="/{embed:category_name}/{segment_3}/{url_title}"><img src="{image}"></a></div>
                    {/if}
                    <div class="post-content" id="{count}">
                        <h3><a href="/{embed:category_name}/{segment_3}/{url_title}">{title}</a>
                        </h3>
                        <p>
                            {exp:word_limit total="15"}
                            {body}
                            {/exp:word_limit}
                        </p>
                    </div>
                    {/if}
                </div>
            </div>
            {/exp:channel:entries}
            <!-- /Cols -->
        </div>
        <!-- /Cols 9 -->
        <div class="col-md-3 col-sm-3">
            <div class="add">
                {ad_300x100_general_top}
            </div>
            <div class="add">
                {ad_300x100_general_top}
            </div>
        </div>
        <!-- /Cols -->
    </div>
</section>

PHP ON INPUT

What I did :

  1. Removed the exit
  2. Removed the angled quoates from around your php tags

Please let us know how you fair with this...

5
  • If exit is remove it is redirect to another page. Jul 8, 2015 at 5:01
  • HI Padam, in that case you will need to look at the routing of your site, and find out where exactly that redirect is, because its in the template you shared. Generally I set up an AJAX route so that the template can be reached directly, not via any layout or index templates you might have. Or it could be that you arn't returning false in your Javascript and so the anchor tag is being followed?
    – Blatant
    Jul 8, 2015 at 8:36
  • Is it ok if we could discuss this matter in a chat ? Jul 8, 2015 at 8:53
  • Sorry Padam, I am at work and quite busy so I can't chat at the moment. Sorry.
    – Blatant
    Jul 8, 2015 at 9:27
  • so when you are free please add my skype address padam.shankhadev1 I am in really need of some help. I am not able to move further in my project. Jul 8, 2015 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.