Search
Other Articles Anywhere questions
Forum

If empty above content...

Stephan Herby's Avatar Stephan Herby
Hi Peter,
I have a case here I don't know if it is possible or if there's a solution. I need your advice...
I have a slider showing "Comments" for formation. they are link by "Articles Field" plugin to Formations with "Article Anywhere" module.
It is working as expected.
This is my code in the module :
<h2 class="uk-h3 uk-font-tertiary uk-text-muted uk-margin uk-margin-small-bottom uk-text-uppercase"><span uk-icon="icon: comments" class="uk-margin-small-right uk-icon"></span> Témoignages</h2>
	
<div class="uk-slider-container-offset" uk-slider="autoplay: true; autoplay-interval: 4000; pause-on-hover: true">
	<div class="uk-position-relative uk-visible-toggle" tabindex="-1">
		<ul class="uk-slider-items uk-child-width-1-1 uk-grid">{articles category="temoignages" commentaires-formation="this:id" ordering="created DESC" empty="Pas de témoignage sur cette formation pour l'instant"}
			<li>
				<div class="uk-card uk-card-default uk-card-small">
					<div class="uk-card-body">
						<h3 class="uk-h4 uk-font-tertiary uk-margin-small-top uk-margin-remove-bottom">[title]</h3>
						<img alt="[title]" width="150" height="28" class="uk-margin-small" src="images/formations/rate/temoignage-rate-etoile-[commentaire-note output='value'].png" alt="Note : [commentaire-note output='value']/5" />
						<p class="uk-margin-remove">[text]</p>
						<p class="uk-margin-small-top uk-text-small"><span class="uk-text-bold">[commentaire-nom]</span> - [commentaire-entreprise]</p>
					</div>
				</div>
			</li>
			{/articles}
		</ul>
	</div>
	<ul class="uk-slider-nav uk-dotnav uk-flex-center uk-margin"></ul>
</div>
Know the H2 tag is the title of the slider and I want it to appear only if there's some content in the slider. I have already tried the "Hide if empty" option in the module, but it does not work (as probably there's some "div" before the content it self.
A screenshot is better then words 😉
www.dropbox.com/s/6dak72okm27hv23/regula...-not-appear.png?dl=0
Any advice for this case ?
Stephan Herby's Avatar Stephan Herby
Hi Peter, Sorry to bother you with this, I found a solution by Myself.
Maybe any advice to optimize it or it is good as it is ?
<!-- TEMOIGNAGE STRATEGIC -->
	
{articles category="temoignages" commentaires-formation="this:id" limit="1"}
<h2 class="uk-h3 uk-font-tertiary uk-text-muted uk-margin uk-margin-small-bottom uk-text-uppercase"><span uk-icon="icon: comments" class="uk-margin-small-right uk-icon"></span> Témoignage(s)</h2>
{/articles}	
<div class="uk-slider-container-offset" uk-slider="autoplay: true; autoplay-interval: 4000; pause-on-hover: true">
	<div class="uk-position-relative uk-visible-toggle" tabindex="-1">
		<ul class="uk-slider-items uk-child-width-1-1 uk-grid" uk-height-match="target: > li > .uk-card">{articles category="temoignages" commentaires-formation="this:id" ordering="created DESC"  limit="50"}
			<li>
				<div class="uk-card uk-card-default uk-card-small">
					<div class="uk-card-body">
						<h3 class="uk-h4 uk-font-tertiary uk-margin-small-top uk-margin-remove-bottom">[title]</h3>
						<img alt="[title]" width="150" height="28" class="uk-margin-small" src="images/formations/rate/temoignage-rate-etoile-[commentaire-note output='value'].png" alt="Note : [commentaire-note output='value']/5" />
						<p class="uk-margin-remove">[text]</p>
						<p class="uk-margin-small-top uk-text-small"><span class="uk-text-bold">[commentaire-nom]</span> - [commentaire-entreprise]</p>
					</div>
				</div>
			</li>
			{/articles}
		</ul>
	</div>
	<ul class="uk-slider-nav uk-dotnav uk-flex-center uk-margin"></ul>
</div>
Peter van Westen's Avatar Peter van Westen ADMIN
You can also use the {if first} and {if last} to add the stuff you don't want repeated:
{articles category="temoignages" commentaires-formation="this:id"}

{if first}
	<h2 ...>...</h2>

	<div ...>
		<div ...>
			<ul ...>
{/if}

				<li>...</li>

{if last}
			</ul>
		</div>
		<ul ...></ul>
	</div>
{/if}

{/articles}
Please post a rating at the Joomla! Extensions Directory
Stephan Herby's Avatar Stephan Herby
Great ! Works much more better ! 🙂
And you just gave me an idea for another use ! 🙂
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription