A
A
Alexon Classic2018-12-04 17:11:09
Joomla
Alexon Classic, 2018-12-04 17:11:09

How to split leading into several different parts with your markup?

Hello everyone !
There is a code (blog.php file) that is responsible for displaying the introductory text, image, etc. of the article in full width:

<?php if (!empty($this->lead_items)) : ?>
        <div class="items-leading clearfix">
      <?php foreach ($this->lead_items as &$item) : ?>
                <div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
          <?php
            $this->item = &$item;
            echo $this->loadTemplate('item');
          ?>
                </div>
        <?php $leadingcount++; ?>
      <?php endforeach; ?>
        </div>
  <?php endif;

I would like to split it into several parts to do something like this:
5c0689b748a22684847277.png
i.e. on the one hand - a slider (already done (without modules)), displaying (for example 3 introductory articles), and on the other - static 3 (4,5...)-and introductory articles... That is, I, in the admin panel, in "Edit Menu Item" --> "Blog Layout Options" --> "Full Width", specify ( for example) the number 6 in the hope that 3 introductory articles will be displayed in the slider, and the rest (next by publication date) 3 introductory articles - to the right of the slider, and already below (let's call it "under the slider") , the rest (next by publication date) introductory articles will be displayed... Well, that is, those introductory articles for which the code is responsible:
<?php if (!empty($this->intro_items)) : ?>
    		<?php foreach ($this->intro_items as $key => &$item) : ?>
    			<?php $rowcount = ((int) $key % (int) $this->columns) + 1; ?>
    			<?php if ($rowcount === 1) : ?>
    				<?php $row = $counter / $this->columns; ?>
                    <div class="items-row cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row-fluid clearfix">
    			<?php endif; ?>
                <div class="span<?php echo round(12 / $this->columns); ?>">
                    <div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
    					<?php
    						$this->item = &$item;
    						echo $this->loadTemplate('item');
    					?>
                    </div>
    
    				<?php $counter++; ?>
                </div>
    
    			<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>
                    </div>
    
    			<?php endif; ?>
    		<?php endforeach; ?>
    	<?php endif;

I hope I explained well what I want ...
Plz tell me how to do it? I understand that I need to somehow prescribe a condition in foreach ... but I don’t understand how to do this ... Thank you in
advance for the answers !
P. _ S. _
  • Use of modules - do not suggest!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexon Classic, 2018-12-04
@AlexonClassic

As always, everything turned out to be as simple as possible!
In the above code (last code in the first post) of the blog.php file, in

<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>

gently insert this line before the loop: and in the foreach loop, replace with to make it look like this:
<?php 
$myarr = array_slice($this->intro_items, 3);
foreach ($myarr_items as $key => &$item) :
?>

then, introductory articles will be displayed not from the first one (if the first article is the last one published), but from the 3rd introductory article. If instead of a triple we put (for example) the 4th, then articles will be displayed starting from the 4th introductory article... Well, I think it's understandable... If it's not clear, try copying the code and experimenting...
Well, where you need to display those introductory articles that we "missed" above, we write the following code:
<?php if (!empty($this->intro_items)) :
$myarr = array_slice($this->intro_items, 0, 3);
foreach ($myarr as $key => &$item) :
$this->item = &$item;
echo $this->loadTemplate('item');
endforeach;
endif; ?>

after which, the missing introductory articles will be displayed.
In order to change the markup of these articles, we replace item with some file of our own, having previously created it in, for example : blog_slider.php. Then instead of item, we write slider.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question