[question] custom theme for home and pages

Post Reply
DawidXT
Sr. Bludit
Posts: 38
Joined: Wed Jul 15, 2015 3:56 pm

Hi, I met a problem.
I am making custom template on bludit CMS. And I am having weird feature issue.

- I changed original homepage from blog to static page and I am trying to set different custom theme for home and different for other pages. But the problem is that even if I change the original home code, it always is injecting code from pages.

example:
elseif($Url->whereAmI()=='home') {
echo '<p>'.$Page->content().'</p>';
}
elseif($Url->whereAmI()=='page') {
echo '<h1>'.$Page->title().'</h1>';
echo '<div>'.$Page->content().'</div>';
}
Gives me one problem. I don't want to see title while I am on homepage, but I want to see it while I am on other pages. The problem right now is, that I actually set a page as a homepage. Bludit lacks better solution for custom theming each page. Once more I would like to see theming system from Monstra CMS here.

Is there any solution how to make it work ?
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:

Do you mean that the following does not work?
DawidXT wrote: example:
elseif($Url->whereAmI()=='home') {
echo '<p>'.$Page->content().'</p>';
}
elseif($Url->whereAmI()=='page') {
echo '<h1>'.$Page->title().'</h1>';
echo '<div>'.$Page->content().'</div>';
}
What is the if-condition before the two elseif?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
DawidXT
Sr. Bludit
Posts: 38
Joined: Wed Jul 15, 2015 3:56 pm

Edi - it works, but look:

- My homepage is "page" static page, not blog. How I can by this two combination give different layout to page that is on homepage, and other layout to other pages?

Just I want to make my homepage to look different than other pages.
But both this code uses the same layout.

This is my whole code

Code: Select all

<?php
			        if( $Url->whereAmI()=='blog' ) {

                        echo '<div class="col-1">';
                            foreach($posts as $Post) {
                                include(PATH_THEME_PHP.'post.php');
                            }
                        echo '</div>';
                        echo '<div class="col-2">';
                        include(PATH_THEME_PHP.'sidebar.php');
                        echo '</div>';
			        }
                    elseif($Url->whereAmI()=='home') {
                        echo '<p>'.$Page->content().'</p>';

			        }
			        elseif($Url->whereAmI()=='post') {

                        echo '<div class="col-1">';
                            foreach($posts as $Post) {
                                include(PATH_THEME_PHP.'post-detail.php');
                            }
                        echo '</div>';
                        echo '<div class="col-2">';
                        include(PATH_THEME_PHP.'sidebar.php');
                        echo '</div>';

			        }
			        elseif($Url->whereAmI()=='page') {
			            echo '<div>'.$Page->content().'</div>';
			        }
			    ?>
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:

I have to test it...
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Fred
Legend Bludit
Posts: 236
Joined: Wed Jun 24, 2015 2:14 pm
Location: France
Contact:

Hi,
Re place the index theme file with this par of code:

Code: Select all

	<!-- Wrapper -->
	<div id="wrapper">

		<!-- Main -->
		<div id="main">

			<?php
			    if( ($Url->whereAmI()=='home') || ($Url->whereAmI()=='tag') || ($Url->whereAmI()=='blog') )
			    {
			        include(PATH_THEME_PHP.'home.php');
			    }
			    elseif($Url->whereAmI()=='post')
			    {
			        include(PATH_THEME_PHP.'post.php');
			    }
			    elseif($Url->whereAmI()=='page')
			    {
				    $template = PATH_THEME_PHP. $Page->slug(). '.php';
				    if(file_exists($template))
					    include_once($template);
				    else 
					    include(PATH_THEME_PHP.'page.php');				    
			    }
			?>

		</div>

		<!-- Show the sidebar if the user is in home -->
		<?php if( ($Url->whereAmI()=='home') || ($Url->whereAmI()=='tag') || ($Url->whereAmI()=='blog') ): ?>

		<!-- Sidebar -->
		<section id="sidebar">
		<?php include(PATH_THEME_PHP.'sidebar.php') ?>
		</section>

		<?php endif; ?>

	</div>
Now look the page slug in admin and in your theme, duplicate the page.php layout in your slug page name (wihout /).
Image
If you don't have custom layout, page.php is by default selected.

I think get this tip natively in Bludit for extend page layout in futur.
╰☆╮Bludit╰☆╮ is a open source and community contributions are essential to project success!
You are looking for a light forum based Json? Try my project Flatboard, it is free. ;)
Sorry for my little english, i'm french :oops:
User avatar
jmonroe
Sr. Bludit
Posts: 38
Joined: Mon Feb 22, 2016 8:06 am
Location: USA
Contact:

I think that adding that as a tip is a great idea and definitely great bit of information.
Jeremy Monroe
I Support Bludit via Patreon
DawidXT
Sr. Bludit
Posts: 38
Joined: Wed Jul 15, 2015 3:56 pm

ok, i got Your point. Now I can separate the templates for individual page - Thank You.

By the way: You see, why everyone is talking about "custom" template for each page. It should be implemented by default inside dashboard.

@chunk head
@chunk header
@body - checked if is default in specific page or customized in dashboard.
@chunk footer

once again, I love the Monstra CMS solution of theming.
And from this point... I think Bludit needs theme manager in dashboard, like Monstra does.
Of course I am not talking about doing everything the same as it is there, but to take best solutions from there, fix the bad - do it better. I always loved to make themes for that CMS. I am almost finished my first theme for Bludit - What a pity there is no a showcase on this forum :)
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:

DawidXT wrote:What a pity there is no a showcase on this forum :)
It's on the to do list.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Fred
Legend Bludit
Posts: 236
Joined: Wed Jun 24, 2015 2:14 pm
Location: France
Contact:

Up this topic for place this code natively in template.
replace:

Code: Select all

			<?php
			    if( ($Url->whereAmI()=='home') || ($Url->whereAmI()=='tag') || ($Url->whereAmI()=='blog') )
			    {
			        include(THEME_DIR_PHP.'home.php');
			    }
			    elseif($Url->whereAmI()=='post')
			    {
			        include(THEME_DIR_PHP.'post.php');
			    }
			    elseif($Url->whereAmI()=='page')
			    {
			        include(THEME_DIR_PHP.'page.php');
			    }
			?>
by:

Code: Select all

			<?php
			    if( ($Url->whereAmI()=='home') || ($Url->whereAmI()=='tag') || ($Url->whereAmI()=='blog') )
			    {
			        include(THEME_DIR_PHP.'home.php');
			    }
			    elseif($Url->whereAmI()=='post')
			    {
				    $Post_template = PATH_THEME_PHP. $Post->slug(). '.php';
					if( Sanitize::pathFile(PATH_THEME_PHP, $Post->slug(). '.php') ) 
						include($Post_template);
					else 	    ;				    
						include(THEME_DIR_PHP.'post.php');
			    }
			    elseif($Url->whereAmI()=='page')
			    {
				    $Page_template = PATH_THEME_PHP. $Page->slug(). '.php';
					if( Sanitize::pathFile(PATH_THEME_PHP, $Page->slug(). '.php') ) 
						include($Page_template);
					else 	    
			        	include(THEME_DIR_PHP.'page.php');
			    }
			?>
It's not much, but it allows to really customize pages and posts about Bludit ;)
╰☆╮Bludit╰☆╮ is a open source and community contributions are essential to project success!
You are looking for a light forum based Json? Try my project Flatboard, it is free. ;)
Sorry for my little english, i'm french :oops:
mary
Jr. Bludit
Posts: 4
Joined: Mon Aug 08, 2016 11:59 am

My homepage is "page" static page, not blog. How I can by this two combination give different layout to page that is on homepage, and other layout to other pages?
Post Reply