0

Trying to create a list view on the page, which has content like

1.Make

2 Model

3 Description

There are almost 150 such makes, and respective model and short description are added on the list view through pagination - of around 15 or 20 items

I am trying to count respective listing on the page and in between create a lead form view after 7th and 12th listing on every page

However - though all the listing are shown in the page - but the explode function is not executing - no such lead view showing after 7th and 12th listing

Here is the code tried through php explode function in which

<div class="pageing-box-right box-number">
    <div class="pagination pageing-container"><ul>
        <?php echo $this->pagination->getListFooter(); ?></ul>
        <ul><?php //echo $this->pagination->getLimitBox(); ?></ul>
    </div>
</div>

<?php foreach ($this->items as $i => $item) : ?>
    <?php $canEdit = $user->authorise('core.edit', 'com_toys'); ?>
        <?php if (isset($this->items[0]->state)) : ?>
        <?php $class = ($canChange) ? 'active' : 'disabled'; ?>
        <?php endif; ?>

<h3> <?php echo $this->escape($item->n_make); ?>  <?php echo $item->n_model; ?> </h3>
<p> <?php echo $item->n_month; ?>   <?php echo $item->n_year; ?> </p>
<p> <?php echo $item->n_short_description; ?> </p>
<hr/>

        <?php endforeach; ?>

<?php
    $listings = explode("<hr/>", $item->n_make);
    $numberOfListings = count($listings);
    $Reset =1;
    for($i = 0; $i < $numberOfListings; ++$i) 
    {
        if ($Reset == 7)
        { ?> 

        <div style="margin: 0 500px 5px 12px; float: left;">

        <p> Test create form view 1 of lead </p>

  </div>

   <hr />

<p></p>

   <?php } if ($Reset == 12) { ?> 

   <div style="margin: 0 500px 5px 12px; float: left;">

   <p> Test Create Form View 2 of lead </p>
        </br></hr>

   </div>

   <hr />

<p></p>

    <?php }
         echo $listings[$i] . "<hr/>";

         if($Reset>15){
                $Reset =1;
          }
          $Reset++;

    }
    ?>

I believe the problem is in this line in the below code

 $listings = explode("<hr/>", $item->n_make);

Can some one help on it

Here is the listing view - see the lead view which i wish to incorporate after 6/7th listing

Fisher Soft Toys
August 2016
Fisher toys are available at Bernado Store @ 10% Discount
-------------------------------------------

Trudi Soft Toys
August 2016
Trudi Peppy Bear now available. First Order will get first delivery
----------------------------------------------

Hamleys Princess Girl
August 2016
Hamleys Princess girl long awaited is now available online
-----------------------------------------------------------

Acctu
August 2016
Acctu Toys now available for sale in Japan
---------------------------------------------

Bernado Soft Toys
August 2016
Bernado toys are available at Bernado Store @ 10% Discount
-------------------------------------------

V Soft Toys
August 2016
V Bear now available. First Order will get first delivery
----------------------------------------------

**Lead View**
Send you Inquiry now by calling up 001 - 9999999999 or email on - [email protected]
 ------------------------------------------------ 

Jo Princess Girl
August 2016
Jo Princess girl long awaited is now available online
-----------------------------------------------------------

Acctu
August 2016
Acctu Toys now available for sale in Japan
8
  • Do an echo of $item->n_make. Does it contain '<hr/>'s? Commented Aug 7, 2016 at 3:53
  • Did echo, no it does not contain </hr>. However when used - $listings = explode($item->n_make);without it showing error - Warning: explode() expects at least 2 parameters, 1 given in . Also - no change on page list view related to explode Commented Aug 7, 2016 at 3:59
  • What does $item->n_make contain, and ultimately what are you looking for? Commented Aug 7, 2016 at 4:00
  • Hello,. It contains name of make toys like - Fisher, Vombo, Jagoora, Zoom etc i.e different brand of toys. What i am looking at is - to show a lead form view after 7th and 12th listing on the page. Every listing contains make, model and short description of 50 words Commented Aug 7, 2016 at 4:03
  • Edit your question and include the exact output, and what you'd like to get from that output. (ie. "<p>XYZ</p>", "<p>ABC</p>"). I'd like an array of values XYZ and ABC. Commented Aug 7, 2016 at 4:05

1 Answer 1

1

Use this regex to find what you're looking for:

preg_match_all("/(.*?)\s+(?:January|Feburary|March|April|May|June|July|August|September|October|November|December) \d{4}/", $item->n_make, $matches);

$listings = array_map($matches, function($match) {
    return $match[1];
});

//$listings should be an array looking like:
//array('Fisher Soft Toys', 'Trudi Soft Toys', 'Hamleys Princess Girl', etc...)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, any line to be removed, where exactly should this come in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.