How do i create newspaper like show? Topic is solved

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

How do i create newspaper like show?

Post by shaibustephen » Tue Sep 17, 2019 3:19 am

I want to create newspaper-like slideshow on the home page of my site so that every leading and featured article can appear there. To do this, i want to customise my featured.php in the html folder. Please, how do i create slide show to have a dynamic carousel-item -active and carousel-item in the featured.php. This is the sample carousel https://bootsnipp.com/snippets/9xGW.

What changes can i make to the below or which other areas should the appropriate thing be done?
View the featured.php code below

Code: Select all

<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_content
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

JHtml::_('behavior.caption');

// If the page class is defined, add to class as suffix.
// It will be a separate class if the user starts it with a space
?>
<div class="blog-featured text-center<?php echo $this->pageclass_sfx; ?>" itemscope itemtype="https://schema.org/Blog">
<?php if ($this->params->get('show_page_heading') != 0) : ?>
<div class="page-header">
	<h1>
	<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
</div>
<?php endif; ?>
<?php if ($this->params->get('page_subheading')) : ?>
	<h2> 
		<?php echo $this->escape($this->params->get('page_subheading')); ?>
	</h2>
<?php endif; ?>
<?php $leadingcount = 0; ?>
<?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; ?> clearfix"
			itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
			<div class="col-md-6 offset-md-3">
			<?php
				$this->item = &$item;
				echo $this->loadTemplate('item');
			?>
			<div class="border"></div>
			</div><!--offset-->
		</div>
		<?php
			$leadingcount++;
		?>
	<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
	$introcount = count($this->intro_items);
	$counter = 0;
?>
<?php if (!empty($this->intro_items)) : ?>
	<?php foreach ($this->intro_items as $key => &$item) : ?>

		<?php
		$key = ($key - $leadingcount) + 1;
		$rowcount = (((int) $key - 1) % (int) $this->columns) + 1;
		$row = $counter / $this->columns;

		if ($rowcount === 1) : ?>

		<div class="items-row my-5 cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row ">
		<?php endif; ?>
			<div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> col-md-<?php echo round(12 / $this->columns); ?>"
				itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
				<div class="blog-box">
			<?php
					$this->item = &$item;
					echo $this->loadTemplate('item');
			?>
			</div>
			</div>
			<?php $counter++; ?>

			<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>

		</div>
		<?php endif; ?>

	<?php endforeach; ?>
<?php endif; ?>

<?php if (!empty($this->link_items)) : ?>
	<div class="items-more">
	<?php echo $this->loadTemplate('links'); ?>
	</div>
<?php endif; ?>

<?php if ($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2 && $this->pagination->pagesTotal > 1)) : ?>
	<div class="pagination">

		<?php if ($this->params->def('show_pagination_results', 1)) : ?>
			<p class="counter pull-right">
				<?php echo $this->pagination->getPagesCounter(); ?>
			</p>
		<?php endif; ?>
				<?php echo $this->pagination->getPagesLinks(); ?>
	</div>
<?php endif; ?>

</div>
Last edited by toivo on Wed Jan 08, 2020 2:10 am, edited 2 times in total.
Reason: mod note: topic locked on request

 
User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Sat Sep 21, 2019 12:46 am

shaibustephen wrote:
Tue Sep 17, 2019 3:19 am
I want to create newspaper-like slideshow on the home page of my site so that every leading and featured article can appear there. To do this, i want to customise my featured.php in the html folder. Please, how do i create slide show to have a dynamic carousel-item -active and carousel-item in the featured.php. This is the sample carousel https://bootsnipp.com/snippets/9xGW.

What changes can i make to the below or which other areas should the appropriate thing be done?
TIP: Please if you want to post a larg chunk of code, group it under code tags!

Greetings.

It is not as easy to simply change inside featured.php and just like that.

Let me try to explain this in a simple language:

Featured Articles can be overriden if you have an HTML folder on your template and inside one called com_content and other featured which has default.php and default_item.php.

If you see the Featured Articles' Settings you see how many articles are 'Leading' and how many others in columns.
Featured Settings.jpg
Now, where are they? On this Chunk of code:

Code: Select all

<?php $leadingcount = 0; ?>
<?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; ?> clearfix"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<div class="col-md-6 offset-md-3">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
<div class="border"></div>
</div><!--offset-->
</div>
<?php
$leadingcount++;
?>
<?php endforeach; ?>
</div>
<?php endif; ?>
But you need to take into account a couple of things:

First the head of the leading can be replaced with the first three tags of the carousel (do not forget to set properly the closings, and erase the previous tags closings because you might get lost and the template might seem broken for a stray closing tag).

Then the for each lists the Leading items you defined on the list.

Then you have to edit default_item.php so you can arrange it for a single item.

You need as well a couple of Array callings so you can retrieve the titles of the articles for the side list.

The operation is extensive to explain but I hope this could give you a lead.
You do not have the required permissions to view the files attached to this post.
www.aldemar-hernandez.com - Custom templates and design services.

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Sat Oct 19, 2019 3:38 am

i followed your direction. I still have little problem. How do i configure my code as shown below to get ''carousel-item active'' ''carousel-item''?
<div class="carousel-item active">
?
</div><!---carousel item-->
<div class="carousel-item">
?
</div><!---carousel item-->
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>

What should i put at the ? for it to pull up different post items. That is to pull out image and intro text of each category post or article?

User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Sat Oct 19, 2019 4:06 am

shaibustephen wrote:
Sat Oct 19, 2019 3:38 am
i followed your direction. I still have little problem. How do i configure my code as shown below to get ''carousel-item active'' ''carousel-item''?

What should i put at the ? for it to pull up different post items. That is to pull out image and intro text of each category post or article?
I got this solution from a Bootstrap Carousel i made a couple of days ago.

Code: Select all

<?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; ?><?php $paginas = array(); ?>
				<div class="carousel-item <?php if ($row == "0"){echo 'active'; } ?>"><div class="row">
			<?php endif; ?>
           	
			<div class="col-md-<?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>
				<!-- end item -->
				<?php $counter++; ?>
                  
			</div><!-- end span -->
            <?php array_push ($paginas, $filas); ?>
			<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>
			<?php  $filas++;?>  </div></div><!-- end row -->  
			<?php endif; ?>
		<?php endforeach; ?>
This is the exact extract from the solution i did there. The solution i did based on the column block instead of the leading items (since for that solution i needed more than a single item).
If you see the carousel item line it has an if clause which verifies that the row vale begins definitively on 0, throwing the string active on it and if such value is not 0 simply is not summoned. So your solution might be something like this:

Code: Select all

<?php foreach ($this->lead_items as &$item) : ?>
<div class="carousel-item <?php if ($leadingcount === 0){echo "active";} ?>">
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> clearfix"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<div class="col-md-6 offset-md-3">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
<div class="border"></div>
</div><!--offset-->
</div>
</div><!--carousel item-->
<?php
$leadingcount++;
?>
<?php endforeach; ?>
www.aldemar-hernandez.com - Custom templates and design services.

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Sat Oct 19, 2019 11:52 pm

i added it to featured.php and got error message. kindly look at the screenshot on the nature of the error message. Also, view the attached default of the featured folder and help me correct it. I want aleast four carousel items on it.

I really appreciate your prompt response
You do not have the required permissions to view the files attached to this post.

User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Sun Oct 20, 2019 12:46 am

shaibustephen wrote:
Sat Oct 19, 2019 11:52 pm
i added it to featured.php and got error message. kindly look at the screenshot on the nature of the error message. Also, view the attached default of the featured folder and help me correct it. I want aleast four carousel items on it.

I really appreciate your prompt response
If i need to correct the file i'll need the whole (structure of the) template in order to do the override properly.
www.aldemar-hernandez.com - Custom templates and design services.

User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Sun Oct 20, 2019 12:50 am

And this does not make sense . Line 33 is a closing div tag and the error says about a leading count on such line.

I would need as well the untouched template something is fishy
You do not have the required permissions to view the files attached to this post.
www.aldemar-hernandez.com - Custom templates and design services.

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Sun Oct 20, 2019 1:05 am

here below is an untouched template
You do not have the required permissions to view the files attached to this post.

User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Sun Oct 20, 2019 1:17 am

I see what is happening:

The custom code is BEFORE of the leading count calling. Your default.php must work this way. Check it out carefully

Code: Select all

<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_content
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

JHtml::_('behavior.caption');

// If the page class is defined, add to class as suffix.
// It will be a separate class if the user starts it with a space
?>

<div class="blog-featured<?php echo $this->pageclass_sfx; ?>" itemscope itemtype="https://schema.org/Blog">
<?php if ($this->params->get('show_page_heading') != 0) : ?>
<div class="page-header">
	<h1>
	<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
</div>
<?php endif; ?>
<?php if ($this->params->get('page_subheading')) : ?>
	<h2> 
		<?php echo $this->escape($this->params->get('page_subheading')); ?>
	</h2>
<?php endif; ?>
<?php $leadingcount = 0; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading clearfix">
    <?php foreach ($this->lead_items as &$item) : ?>
<div class="carousel-item <?php if ($leadingcount === 0){echo "active";} ?>">
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> clearfix"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<div class="col-md-6 offset-md-3">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
<div class="border"></div>
</div><!--offset-->
</div>
</div><!--carousel item-->
<?php
$leadingcount++;
?>
<?php endforeach; ?>
    
	<?php /*foreach ($this->lead_items as &$item) : ?>
		<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> clearfix"
			itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
			<?php
				$this->item = &$item;
				echo $this->loadTemplate('item');
			?>
		</div>
		<?php
			$leadingcount++;
		?>
	<?php endforeach; */?>
</div>
<?php endif; ?>
<?php
	$introcount = count($this->intro_items);
	$counter = 0;
?>
<?php if (!empty($this->intro_items)) : ?>
	<?php foreach ($this->intro_items as $key => &$item) : ?>

		<?php
		$key = ($key - $leadingcount) + 1;
		$rowcount = (((int) $key - 1) % (int) $this->columns) + 1;
		$row = $counter / $this->columns;

		if ($rowcount === 1) : ?>

		<div class="items-row cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row-fluid row">
		<?php endif; ?>
			<div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> col-md-<?php echo round(12 / $this->columns); ?>"
				itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
			<?php
					$this->item = &$item;
					echo $this->loadTemplate('item');
			?>
			</div>
			<?php $counter++; ?>

			<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>

		</div>
		<?php endif; ?>

	<?php endforeach; ?>
<?php endif; ?>

<?php if (!empty($this->link_items)) : ?>
	<div class="items-more">
	<?php echo $this->loadTemplate('links'); ?>
	</div>
<?php endif; ?>

<?php if ($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2 && $this->pagination->pagesTotal > 1)) : ?>
	<div class="pagination">

		<?php if ($this->params->def('show_pagination_results', 1)) : ?>
			<p class="counter pull-right">
				<?php echo $this->pagination->getPagesCounter(); ?>
			</p>
		<?php endif; ?>
				<?php echo $this->pagination->getPagesLinks(); ?>
	</div>
<?php endif; ?>

</div>

On the Menu item place 4 leading articles. If you have more, try with them.
www.aldemar-hernandez.com - Custom templates and design services.

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Thu Jan 02, 2020 12:35 am

Look at the below. It is not sliding. what am i missing out here?

<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class=""></li>
<li data-target="#myCarousel" data-slide-to="1" class=""></li>
<li data-target="#myCarousel" data-slide-to="2" class="active"></li>
</ol>
<div class="carousel-inner">
<?php $leadingcount = 0; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading clearfix">
<?php foreach ($this->lead_items as &$item) : ?>
<div class="carousel-item <?php if ($leadingcount === 0){echo "active";} ?>">
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> clearfix"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</div>
</div><!--carousel item-->
<?php
$leadingcount++;
?>
<?php endforeach; ?>

<?php /*foreach ($this->lead_items as &$item) : ?>
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> clearfix"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</div>
<?php
$leadingcount++;
?>
<?php endforeach; */?>
</div>
<?php endif; ?>
<a class="carousel-control-prev" href="https://getbootstrap.com/docs/4.3/examp ... myCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="https://getbootstrap.com/docs/4.3/examp ... myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>

User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Thu Jan 02, 2020 12:26 pm

shaibustephen wrote:
Thu Jan 02, 2020 12:35 am
Look at the below. It is not sliding. what am i missing out here?
Does not Slide At All or slides once you move the first one?

PD : Next time you post Code use the Code Tag
www.aldemar-hernandez.com - Custom templates and design services.

User avatar
john-doe
Joomla! Guru
Joomla! Guru
Posts: 967
Joined: Tue Apr 19, 2011 7:39 pm
Location: Colombia
Contact:

Re: How do i create newspaper like show?

Post by john-doe » Thu Jan 02, 2020 12:29 pm

And i would like to see a live preview of this because i need to see what throws at console
www.aldemar-hernandez.com - Custom templates and design services.

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Fri Jan 03, 2020 2:02 am

Alternatively, how do i create a dynamic php bootstrap carousel slide that draws content, image, text excerpt and text links from the article post.
I got a video somewhere on how to same but with large error. Take a look at it and let me know how to create same in joomla

Code: Select all

  <div id="dynamic_slide_show" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
      <?php echo make_slide_indicators($connect); ?>
    </ol>
    <div class="carousel-inner">
     <?php echo make_slides($connect); ?>
    </div>
    <a class="carousel-control-prev" href="#dynamic_slide_show" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#dynamic_slide_show" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>


<?php
// carousel slide
$connect = mysqli_connect("localhost", "root",  "", "testing");
function make_query($connect){
	$query="SELECT * FROM banner ORDER BY banner_id ASC";
	$result = mysqli_query($connect, $query);
	return $result;
}
function make_slide_indicators($connect){
	$output = '';
	$count = 0;
	$result = make_query($connect);
	while ($row = mysqli_fetch_array($result))
	{
		if($count == 0)
		{
			$output .='
				<li data-target="#dynamic_slide_show" data-slide-to="' .$count.'" class="active"></li>
			';	
		}
		else
		{
		$output .='
				<li data-target="#dynamic_slide_show" data-slide-to="' .$count.'" ></li>
			';		
		}
		$count=$count + 1;
	}
	return $output;
}
function make_slides ($connect){
	$output ='';
	$count == 0;
	$result = make_query($connect);
	while ($row = mysqli_fetch_array($result)){
	if($count == 0)
		{
			$output .='<div class="carousel-item active">';	
		}
		else
		{
		$output .='<div class="carousel-item">';		
		}
		$output .=' <img src="images/'.$row["banner_image"].'" alt="'.$row["banner_title"].'"/>
			<div class="carousel-caption text-right">
				<h1>'.$row["banner_title"].'</h1>
			</div>
			</div>
		';
			$count= $count + 1;
	}
	return $output;
}
?>
Last edited by toivo on Fri Jan 03, 2020 5:56 am, edited 1 time in total.
Reason: mod note: added code tag

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 11921
Joined: Thu Feb 15, 2007 5:48 am
Location: Suzhou, China

Re: How do i create newspaper like show?

Post by toivo » Fri Jan 03, 2020 5:58 am

@shaibustephen, please use the code tag when you post code. As requested by @john-doe, can you also please post the URL.
Toivo Talikka, Global Moderator

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Sat Jan 04, 2020 11:56 pm

I will subsequently do that. Please, how do i put tag on this post? I appreciate

This is the attached copied and the complete code of the bootstrap carousel slide made in php mysql. Here below is equally the attached screenshot. I followed the video clip on how to make bootstrap carousel slide in php mysql online and arrived at this.
After the whole thing I could not apply it to my joomla database so that it can draw appropriate carousel content from it. Though, previewing the complete worked of bootstrap carousel example above gave me error as it is not working. See the screenshot of the attached error.
What I want now is how to make in such a way that it automatically draw content from joomla database table named ‘’content’’.
How do I achieve this? My database name=brown, username=admin, password=Ojate123.
Here below is the complete sql of the database.


// carousel slide
$connect = mysqli_connect("localhost", "root", "", "testing");
function make_query($connect){
$query="SELECT * FROM banner ORDER BY bnner_id ASC";
$result = mysqli_query($connect, $query);
return $result;
}
function make_slide_indicators($connect){
$output = '';
$count = 0;
$result = make_query($connect);
while ($row = mysqli_fetch_array($result))
{
if($count == 0)
{
$output .='
<li data-target="#dynamic_slide_show" data-slide-to="' .$count.'" class="active"></li>
';
}
else
{
$output .='
<li data-target="#dynamic_slide_show" data-slide-to="' .$count.'" ></li>
';
}
$count = $count + 1;
}
return $output;
}


function make_slides($connect){
$output ='';
$count = 0;
$result = make_query($connect);
while ($row = mssql_fetch_array($result)){
if($count ==0)
{
$output .='<div class="carousel-item active">';
}
else
{
$output .='<div class="carousel-item ">';
}
$output .='<img src="images/'.$row["banner_image"].'" alt="'.$row["banner_title"].'"/>
<div class="carousel-caption">
<h3>'.$row["banner_title"].'</h3>
</div>
</div>
' ;
$count = $count + 1;
}
return $output;
}


<div id="dynamic_slide_show" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php echo make_slide_indicators($connect); ?>
</ol>
<div class="carousel-inner">
<?php echo make_slides($connect); ?>
</div>
<a class="carousel-control-prev" href="#dynamic_slide_show" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#dynamic_slide_show" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
You do not have the required permissions to view the files attached to this post.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 11921
Joined: Thu Feb 15, 2007 5:48 am
Location: Suzhou, China

Re: How do i create newspaper like show?

Post by toivo » Sun Jan 05, 2020 1:21 am

shaibustephen wrote:how do i put tag on this post?
Click 'Full Editor & Preview' and hover the cursor above the icon that looks like this </> and you will see the format of the code start and end tags.

Just select the text you want included in the code block and then click </> and the tags will be inserted automatically. Otherwise just type them in manually.

Check also the Options tab below and make sure that you have not disabled BBCode.
Toivo Talikka, Global Moderator

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Sun Jan 05, 2020 11:31 pm

After continuous trying, my php carousel slide is working but still have little error in the code below. View the screenshot. What am i missing out in the php code. Also, i want the carousel to draw content images irrespective of image folder, what should i change in the code.

These are the errors from the carousel slide
Notice: Undefined variable: count in C:\xampp\htdocs\brown\templates\brown\index.php on line 99

Notice: Undefined variable: count in C:\xampp\htdocs\brown\templates\brown\index.php on line 102

Notice: Undefined variable: count in C:\xampp\htdocs\brown\templates\brown\index.php on line 116
line 99 $count == 0;
line 102 if($count == 0)
line 116 $count= $count + 1;
kindly view the complete code below

Code: Select all

<?php
/**
 * @package     Joomla.Site
 * @subpackage  Templates.brown
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Getting params from template
$params = $app->getTemplate(true)->params;

// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = $app->get('sitename');

if ($task == "edit" || $layout == "form") {
    $fullWidth = 1;
} else {
    $fullWidth = 0;
}

// Add Stylesheets
$doc->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/bootstrap.min.css');
$doc->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/font-awesome.min.css');
$doc->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/template.css');

// Add scripts
JHtml::_('jquery.framework');
$doc->addScript($this->baseurl . '/templates/' . $this->template . '/js/bootstrap.bundle.js');
$doc->addScript($this->baseurl . '/templates/' . $this->template . '/js/template.js');

// Adjusting content width
if ($this->countModules('sidebar-1') && $this->countModules('sidebar-2')) {
    $span = "col-md-6";
} elseif ($this->countModules('sidebar-1') && !$this->countModules('sidebar-2')) {
    $span = "col-md-9";
} elseif (!$this->countModules('sidebar-1') && $this->countModules('sidebar-2')) {
    $span = "col-md-9";
} else {
    $span = "col-md-12";
}

// Logo file or site title param
if ($this->params->get('logoFile'))
{
	$logo = '<img src="' . JUri::root() . $this->params->get('logoFile') . '" alt="' . $sitename . '" />';
}
elseif ($this->params->get('sitetitle'))
{
	$logo = '<span class="site-title" title="' . $sitename . '">' . htmlspecialchars($this->params->get('sitetitle'), ENT_COMPAT, 'UTF-8') . '</span>';
}
else
{
	$logo = '<span class="site-title" title="' . $sitename . '">' . $sitename . '</span>';
}
// carousel slide
$connect = mysqli_connect("localhost", "root",  "", "brown");
function make_query($connect){
	$query="SELECT * FROM `i5upv_content` ORDER BY `i5upv_content`.`id` ASC ";
	$result = mysqli_query($connect, $query);
	return $result;
}
function make_slide_indicators($connect){
	$output = '';
	$count = 0;
	$result = make_query($connect);
	while ($row = mysqli_fetch_array($result))
	{
		if($count == 0)
		{
			$output .='
				<li data-target="#carouselExampleSlidesOnly" data-slide-to="' .$count.'" class="active"></li>
			';	
		}
		else
		{
		$output .='
				<li data-target="#carouselExampleSlidesOnly" data-slide-to="' .$count.'" ></li>
			';		
		}
		$count=$count + 1;
	}
	return $output;
}
function make_slides ($connect){
	$output ='';
	$count == 0;
	$result = make_query($connect);
	while ($row = mysqli_fetch_array($result)){
	if($count == 0)
		{
			$output .='<div class="carousel-item active">';	
		}
		else
		{
		$output .='<div class="carousel-item">';		
		}
		$output .=' <img src="images/'.$row["images"].'" alt="'.$row["title"].'"/>
			<div class="carousel-caption text-right">
				<h1>'.$row["title"].'</h1>
			</div>
			</div>
		';
			$count= $count + 1;
	}
	return $output;
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <jdoc:include type="head" />
        <?php if($this->params->get('favicon')) { ?>
            <link rel="shortcut icon" href="<?php echo JUri::root(true) . htmlspecialchars($this->params->get('favicon'), ENT_COMPAT, 'UTF-8'); ?>" />
        <?php } ?>
        <!--[if lt IE 9]>
                <script src="<?php echo JUri::root(true); ?>/media/jui/js/html5.js"></script>
        <![endif]-->
    </head>
    <body>



<!-- Navigation -->
<nav class="navbar navbar-expand-md justify-content-start flex-nowrap">
   <div class="container">
    <ul class="navbar-nav flex-row ml-auto">
        <li class="nav-item active">
            <a class="nav-link px-2" href="#">Link</a>
        </li>
        <li class="nav-item">
            <a class="nav-link px-2" href="#">Link</a>
        </li>
        <li class="nav-item">
            <a class="nav-link px-2" href="#">Link</a>
        </li>
    </ul>
    </div><!--container-->
</nav>

<nav class="navbar navbar-expand-md bg-light navbar-light sticky-top">
   <div class="container">
     <a class="navbar-brand" href="<?php echo $this->baseurl; ?>/"><?php echo $logo; ?>
							<?php if ($this->params->get('sitedescription')) : ?>			
							<?php echo '<div class="site-description">' . htmlspecialchars($this->params->get('sitedescription'), ENT_COMPAT, 'UTF-8') . '</div>'; ?>
							<?php endif; ?></a>
							    <button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbar2">
         <span class="fa fa-bars"></span>
    </button>
    <div class="navbar-collapse collapse pt-2 pt-md-0" id="navbar2">
        <ul class="navbar-nav ml-auto  navbarNav">
          <jdoc:include type="modules" name="mnu" style="none" />
        </ul>
        <div class="my-2 my-md-0 social">
			<jdoc:include type="modules" name="head-social" style="none" />
		</div>
    </div>
   </div><!--container-->
</nav>

        <div class="body">
            <div class="content">
                <div class="jumbotron jumbotron-fluid bg-primary text-white">
                    <div class="container<?php echo ($params->get('fluidContainer') ? '-fluid' : ''); ?>">
                        <?php if(JURI::base() == JURI::current()) { ?>
                            <h1><?php echo $app->get('sitename'); ?></h1>
                                <?php if ($this->params->get('sitedescription')) { ?>
                                    <p class="lead">
                                        <?php echo htmlspecialchars($this->params->get('sitedescription'), ENT_COMPAT, 'UTF-8'); ?>
                                    </p>
                                <?php }?>
                        <?php } else {?>
                            <h1><?php echo $this->getTitle();; ?>
                        <?php } ?>
                    </div>
                </div>
                

  <div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
      <?php echo make_slide_indicators($connect); ?>
    </ol>
    <div class="carousel-inner">
     <?php echo make_slides($connect); ?>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleSlidesOnly" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleSlidesOnly" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>


                <div class="container<?php echo ($params->get('fluidContainer') ? '-fluid' : ''); ?>">
                    <jdoc:include type="modules" name="banner" style="xhtml" />
                    <?php if ($this->countModules('breadcrumbs')) : ?>
                        <div class="row">
                            <div class="col-sm-12">
                                <jdoc:include type="modules" name="breadcrumbs" style="xhtml" />
                            </div>
                        </div>
                    <?php endif; ?>
                    <div class="row">
                        <?php if ($this->countModules('sidebar-1')) : ?>
                            <div id="sidebar" class="col-md-3">
                                <div class="sidebar-nav">
                                    <jdoc:include type="modules" name="sidebar-1" style="xhtml" />
                                </div>
                            </div>
                        <?php endif; ?>
                        <main id="content" role="main" class="<?php echo $span; ?>">
                            <jdoc:include type="modules" name="position-3" style="xhtml" />
                            <jdoc:include type="message" />
                            <jdoc:include type="component" />
                            <jdoc:include type="modules" name="position-2" style="none" />
                        </main>
                        <?php if ($this->countModules('sidebar-2')) : ?>
                            <div id="aside" class="col-md-3">
                                <jdoc:include type="modules" name="sidebar-2" style="xhtml" />
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
        <footer class="footer bg-faded text-muted" role="contentinfo">
            <hr />
            <div class="container<?php echo ($params->get('fluidContainer') ? '-fluid' : ''); ?>">
                <div class="row">
                    <div class="col-sm-4"><p>
                            &copy; <?php echo date('Y'); ?> <?php echo $sitename; ?>
                        </p>
                    </div>
                    <div class="col-sm-4 text-center">
                        <jdoc:include type="modules" name="footer" style="none" />
                        <p></p>
                    </div>
                    <div class="col-sm-4">
                        <p class="text-right">
                            <a href="#top" id="back-top">
                                <i class="fa fa-arrow-up"></i> <?php echo JText::_('TPL_BROWN_BACKTOTOP'); ?>
                            </a>
                        </p>
                    </div>
                </div>
            </div>
        </footer>
        <jdoc:include type="modules" name="debug" style="none" />
    </body>
</html>
You do not have the required permissions to view the files attached to this post.

User avatar
sozzled
Joomla! Exemplar
Joomla! Exemplar
Posts: 8559
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: How do i create newspaper like show?

Post by sozzled » Sun Jan 05, 2020 11:44 pm

Line 99: wrong assignment operator for variable $count. Therefore, lines 102 and 106 cannot execute. See https://www.w3schools.in/php/operators/ ... operators/
https://www.kuneze.com/blog
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Sun Jan 05, 2020 11:52 pm

I appreciate sir. I am just new in php coding. Please, what should i change the concerned lines to get ride of the errors and to make it work properly? Also, i want it to draw images irrespective of the image folders. what should i add.

Thanks for helping

shaibustephen
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 194
Joined: Sat Nov 17, 2018 1:52 pm

Re: How do i create newspaper like show?

Post by shaibustephen » Tue Jan 07, 2020 12:25 pm

I have resolved the error massage and working fine. The next problem is that the title, images and intro text of the carousel are not showing even though it is sliding.

It will surprise you to note that when I view the source code in the browser every thing are there intact.

What am i missing that makes these not to show in the browser when preview.

Help me study the code properly

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 11921
Joined: Thu Feb 15, 2007 5:48 am
Location: Suzhou, China

Re: How do i create newspaper like show?

Post by toivo » Wed Jan 08, 2020 2:09 am

Please create a new topic about the new problem and provide the URL of the website with the FPA results. If you attach code, remember to use the code tags.
Toivo Talikka, Global Moderator

 

Locked

Return to “Templates for Joomla! 3.x”