Static home page and blog via a menu item ?

LucyDemoon
Ssr. Bludit
Posts: 11
Joined: Thu May 18, 2023 7:55 pm

in the template index.php have i this code:

Code: Select all

    <?php
        if ($WHERE_AM_I == 'page') {
            if ($page->isStatic()) {
                if ($page->category('nav-games') && !$page->isParent()) {
                    include(THEME_DIR_PHP.'static-games.php');
                } elseif($WHERE_AM_I == 'home' or $page->slug() === 'home') {
                    include(THEME_DIR_PHP.'home.php');
                    include(THEME_DIR_PHP.'footer.php');
                } else {
                    include(THEME_DIR_PHP . 'static.php');
                }
            } else {
                include(THEME_DIR_PHP.'page.php');
            }
        } else {
            include(THEME_DIR_PHP . 'news.php');
        }
    ?>
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

What is the code of the template news.php?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
LucyDemoon
Ssr. Bludit
Posts: 11
Joined: Thu May 18, 2023 7:55 pm

Code: Select all

<section class="page-header">
	<div class="container">
		<div class="row justify-content-center">
			<div class="col-lg-7 col-md-9">
				<div class="cont text-center">
					<h1 class="mb-10 color-font"><?php echo $page->title(); ?></h1>
					<?php if ($page->description()): ?>
						<p><?php echo $page->description(); ?></p>
					<?php endif ?>
				</div>
			</div>
		</div>
	</div>
</section>
<section class="blog-pg single section-padding pt-0">
	<div class="container">
		<div class="row justify-content-center">
			<div class="col-lg-11">
				<div class="post">
					<?php Theme::plugins('pageBegin'); ?>
					<?php if ($page->coverImage()): ?>
						<div class="img">
							<img src="<?php echo $page->coverImage(); ?>" alt="">
						</div>
					<?php endif ?>
					<div class="content pt-60">
						<div class="row justify-content-center">
							<div class="col-lg-10">
								<div class="cont">
									<?php echo $page->content(); ?>
								</div>
								<div class="author">
									<div class="author-img">
										<img src="<?php echo $page->user('profilePicture'); ?>" alt="">
									</div>
									<div class="info">
										<h6><span>author :</span> <?php echo $page->user('firstName'); ?> (<?php echo $page->user('nickname'); ?>)</h6>
										<p class="text-black-50">
											<span><?php echo $L->p("Erstellt am: ")?></span>
											<span><?php echo $page->date(); ?></span>
										</p>
									</div>

								</div>

							</div>
						</div>
					</div>
					<?php Theme::plugins('pageEnd'); ?>
				</div>
			</div>
		</div>
	</div>
</section>
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Sorry, it's the wrong one. I should have the template with the loop for the slug "blog".
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
LucyDemoon
Ssr. Bludit
Posts: 11
Joined: Thu May 18, 2023 7:55 pm

the news.php is for the slug "blog"
Attachments
Archiv.tar.gz
php files
(6.06 KiB) Downloaded 44 times
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

In the template news.php can the following be found (line 8):

Code: Select all

<?php if ($page->isStatic() and $page->coverImage()): ?>
   <div class="img parlx img-head-nobg">
      <img  src="<?php echo $page->coverImage(); ?>" alt="">
   </div>
<?php else: ?>
   <h1 class="color-font"><?php echo $page->title(); ?></h1>
<?php endif ?>
The else condition shows the title of the first content.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
LucyDemoon
Ssr. Bludit
Posts: 11
Joined: Thu May 18, 2023 7:55 pm

okey and what is the title from static page?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

You can hard code it "News" or something like this.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
LucyDemoon
Ssr. Bludit
Posts: 11
Joined: Thu May 18, 2023 7:55 pm

hm ok, so there is no way to read the title from a static page?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

On a static page the title can be displayed with the following:

Code: Select all

echo $page->title();
But this does not work if the URL filter "/blog/" is set (this works like the page with the template home.php).
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Post Reply