[SOLVED] isStatic doesn't work

Post Reply
ctuxboy
Ssr. Bludit
Posts: 25
Joined: Sat Dec 15, 2018 11:37 pm
Has thanked: 4 times
Been thanked: 2 times

Hello,

Try made custom breadcrumbs, and this is my code:

Code: Select all

<?php if (!$page->isStatic()) { ?>
        <a href="<?php echo Theme::siteUrl() ?>">Home</a> » <a
              href="<?php echo $page->categoryPermalink(); ?>"><?php echo $page->category(); ?></a> » <?php echo $page->title(); ?>
        <?php } else { ?>
          <a href="<?php echo Theme::siteUrl() ?>">Home</a> » <?php echo $page->title(); ?>
        <?php };?>
So when showing a blogpost, this is the breadcrumb:
Home >> Category >> my_blogpost

When showing a static page, it used the same breadcrumb as for blogposts (without category)
Home >> >> my_static_page

Someone knows why the <?php if (!$page->isStatic()) { ?> not work?
Last edited by ctuxboy on Sun Jan 01, 2023 9:13 pm, edited 2 times in total.
kohbarg
Sr. Bludit
Posts: 33
Joined: Tue Jun 11, 2019 11:36 am
Has thanked: 2 times
Been thanked: 2 times

Found another Syntax:

Code: Select all

 if ($WHERE_AM_I == 'page' && !($page->isStatic())) { 
Not (!) ... before the brackets.
ctuxboy
Ssr. Bludit
Posts: 25
Joined: Sat Dec 15, 2018 11:37 pm
Has thanked: 4 times
Been thanked: 2 times

YEAY!!!! THIS WORKS PERFECT!!!
Screenshot 2022-12-31 20.57.11.png
Screenshot 2022-12-31 20.57.11.png (2.73 KiB) Viewed 2019 times

Another question:
When click on a category,
It shows all the pages from this category, but how can i show the following breadcrumb:

Home >> category_name
ctuxboy
Ssr. Bludit
Posts: 25
Joined: Sat Dec 15, 2018 11:37 pm
Has thanked: 4 times
Been thanked: 2 times

Found it!
Follow the documentation:
https://docs.bludit.com/en/dev-snippets/categories

Adding the code to home.php:

Code: Select all

<?php
    // Check if the user is browsing a category
    if ($WHERE_AM_I=='category') {
			// Get the category key from the URL
			$categoryKey = $url->slug();

			// Create the Category-Object
			$category = new Category($categoryKey);
	?>
	<div class="fairy-breadcrumb-wrapper">
		<div class="breadcrumbs init-animate clearfix">
			<div id="fairy-breadcrumbs" class="clearfix">
				<div role="navigation" aria-label="Breadcrumbs" class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">
					<a href="<?php echo Theme::siteUrl() ?>">Home</a> » <?php echo $category->name() ?>
				</div>
			</div>
		</div>
	</div>
	<header class="page-header">
		<h1 class="page-title">Categorie: <?php echo $category->name() ?></h1>
		<div class="taxonomy-description">
			<p><?php echo $category->description(); ?></p>
		</div>
	</header>
	<?php } ?>
And that's the result:
Screenshot 2023-01-01 21.12.19.png
Screenshot 2023-01-01 21.12.19.png (53.92 KiB) Viewed 2008 times
Post Reply