I am new to php language but I need the include() function to separate my site into different PHPs in order to call it again on different pages.All worked fine until I came to include a PHP which includes another PHP . Here's the code in html file :
<?php
set_include_path('contents');
include 'index_page.php';
?>
index_page.php which includes sidebar.php :
<?php
echo
'<div class="body2">
<div class="content">
<h1>text</h1>
<img src="images/homeimage.jpg">
<p>some text</div> '. include "sidebar.php"; '</div>';
?>
sidebar.php:
<?php
echo
'<div id="sidebar">
<ul>
<li><div class="arrow-up"></div>اشترك معنا</li>
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
</ul>
</div>';
?>
The result that appears in the browser was that the sidebar.php was included before the text as if the code was like that :
<?php
echo
include "sidebar.php";.'<div class="body2">
<div class="content">
<h1>text</h1>
<img src="images/homeimage.jpg">
<p>some text</div> </div>';
?>
Any solutions ??
Related
I need to show 4 flexible items and load more, I don't know how to make it manually, so I tried that plugin But I can't understand how to make the shortcode correctly
That's what I generated
[ajax_load_more container_type="div" acf="true" acf_field_type="flexible" acf_field_name="review-repeater" post_type="any" meta_key="review-repeater" meta_value="" meta_compare="IN"]
The original flexible content loop without loadmore
<div class="row justify-content-center">
<?php if( have_rows('review-repeater') ):
// Loop through rows.
while ( have_rows('review-repeater') ) : the_row();?>
<div class="rev">
<?php // Case: Paragraph layout.
if( get_row_layout() == 'review-repeater' ):?>
<div class="d-flex justify-content-between">
<div class="rev-left">
<div class="raiting-review"><?php echo get_sub_field('review-raiting'); ?></div>
<div class="review-content">
<p><?php echo get_sub_field('review-content'); ?></p>
<div class="d-flex">
<?php echo get_sub_field('review-author'); ?> , <?php echo get_sub_field('review-date'); ?>
</div>
</div>
</div>
<div class="rev-right">
<img src="<?php echo get_sub_field('review-platform') ?>">
<p><?php echo get_sub_field('review-count'); ?></p>
</div>
</div>
</div>
<?php endif;
// End loop.
endwhile;
endif; ?>
I copied that code to the 'repeater template' instead of default post archive loop, but the shortcode doesn't show my content, maybe someone already used the same decision?
Already tried posts_per_page="4" parameter, it didn't help too.
I use Glide JS for a Slideshow that I built with ACF and Gutenberg Blocks.
But there is an issue with the next button. The ">" does not get rendered correctly – and it destroyes the whole DOM. Is there an alternative for the "data-glide-dir" next command? When i remove the data-glide-dir=">" everything works just fine.
Below is the code I use – the screenshot shows how it finally gets rendered in the browser.
screenshot
<?php $gallery = get_field('images'); ?>
<?php if( $gallery ) : ?>
<div class="gcont">
<div class="glide">
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">
<?php foreach( $gallery as $image ) : ?>
<li class="glide__slide"><img class="full-width-image" src="<?php echo esc_url($image['sizes']['large']); ?>" alt="<?php echo esc_attr($image['alt']); ?>"></li>
<?php endforeach; ?>
</ul>
</div>
<div class="glide__arrows" data-glide-el="controls">
<button class="glide__arrow glide__arrow--prev" data-glide-dir="<">prev</button>
<button class="glide__arrow glide__arrow--next" data-glide-dir=">">next</button>
</div>
</div>
</div>
<?php endif; ?>
What did the trick for me was encoding < with < and > with >
See also: HTML: Should I encode greater than or not? ( > > )
I am currently making a template in Joomla using Materialize CSS as the framework. I get stuck with the part where I make a dropdown menu in Joomla. The HTML should go as followed (as explained on the documentation page of Materialize)
<!-- Dropdown Structure -->
<ul id="dropdown1" class="dropdown-content">
<li>one</li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<li>
<a class="dropdown-button" href="#!" data-activates="dropdown1">Dropdown<i class="material-icons right">arrow_drop_down</i></a>
</li>
My index.php goes as follows:
<!-- Start Navbar -->
<nav class="indigo" role="navigation">
<div class="nav-wrapper container">
<a id="logo-container" href="index.php" class="brand-logo">
<?php echo $logo; ?>
<?php if ($this->params->get('sitedescription')) : ?>
<?php echo '<div class="site-description">' . htmlspecialchars($this->params->get('sitedescription')) . '</div>'; ?>
<?php endif; ?>
</a>
<ul class="right hide-on-med-and-down">
<jdoc:include type="modules" name="position-1" style="none" />
</ul>
<ul id="nav-mobile" class="side-nav">
<li class="material-menu">
<a href="index.php">
<?php echo $logo; ?>
<?php if ($this->params->get('sitedescription')) : ?>
<?php echo '<div class="site-description">' . htmlspecialchars($this->params->get('sitedescription')) . '</div>'; ?>
<?php endif; ?>
</a>
</li>
<jdoc:include type="modules" name="position-1" style="none" />
</ul>
<i class="mdi mdi-menu"></i>
</div><!-- /nav-wrapper container -->
</nav>
<!-- End Navbar -->
The problem is that I use the menu module twice because of the mobile menu. An ID tag can only be used once so the dropdown doesn't work.
Does anyone know how I can fix this?
Its not a good idea to have the same module position duplicated in the template multiple times as it will render the same markup every time.
Instead, the best approach is to create a copy of the menu module and publish it to your mobile menu position.
In Joomla Admin, duplicate the current menu module
Publish the duplicated menu module to a new position e.g. "mobile-nav". All other settings for this duplicated module can be identical to the original (desktop) menu module.
Update your template code to include position for "mobile-nav" where the mobile navigation should be displayed.
Update template code for new module position (just swap out position-1 with mobile-nav):
<ul id="nav-mobile" class="side-nav">
<li class="material-menu">
<a href="index.php">
<?php echo $logo; ?>
<?php if ($this->params->get('sitedescription')) : ?>
<?php echo '<div class="site-description">' . htmlspecialchars($this->params->get('sitedescription')) . '</div>'; ?>
<?php endif; ?>
</a>
</li>
<jdoc:include type="modules" name="mobile-nav" style="none" />
</ul>
I have this code in template to make a static home button. On the home button on hover over I would like to have a blog button underneath.
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<div class="container_24">
<div class="grid_24">
<div id="menu-icon">Categories</div>
<ul id="nav" class="sf-menu">
<li class="level0 level-top<?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()) echo ' active'; ?>">
<a class="level-top" href="<?php echo $this->getUrl('')?>">
<span>Home</span>
</a>
</li>
<?php echo $_menu ?>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
<?php endif ?>
I'm new to Magento and working on customizing the Modern template, as its close to my ultimate design. However I noticed that for some reason the 3rd column in the 3 column template was commented out:
/frontend/default/modern/template/page/3columns.phtml
[lines 43-55]
<div class="main-container col2-left-layout">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<?php /*<div class="col-wrapper">*/ ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
<div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>
</div>
<?php /*<div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>*/ ?>
<?php /*</div>*/ ?>
</div>
I copied this to my own theme, and modified it as such:
/frontend/my_package/my_theme/template/page/3columns.phtml
<div class="main-container col3-layout"> <-------
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-wrapper"> <-------
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
<div cla/ss="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>
</div>
<div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div> <-------
</div> <-------
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
In the backend, I created a static block with just plain text, and tried adding it to "All Pages", "Right Column"; but it does not show up. If I add it to "All Pages", "Left Column" it does show up.
I'm guessing that the Right Column reference somehow isn't in Magento correctly, but I don't know where to even begin looking to fix that.
You should have a reference to right column in your page.xml (or your custom local.xml) for it to work.
Check this Classyllama article to see how to implement it in correct way:
http://www.classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout