custom page / view / "whereAmI"

Post Reply
matto
Jr. Bludit
Posts: 9
Joined: Fri Feb 19, 2016 6:50 pm

Hi!

I would like to create a custum page.

in my index.php i am using

Code: Select all

                    if ($Url->slug() == "news"){
                        include(THEME_DIR_PHP.'news.php');
                    }elseif ($Url->whereAmI() == 'page') {
                        include(THEME_DIR_PHP.'page.php');
                    } elseif ($Url->whereAmI() == 'post')  {
                        include(THEME_DIR_PHP.'post.php');
                    } elseif ( ($Url->whereAmI()=='blog') || ($Url->whereAmI()=='tag') )  {
                        include(THEME_DIR_PHP.'works.php');
                    }
to load my custom code.

This works good, but bludit throws an error, that i cant build a page object for "news". Creating a "news" page solves this.

Is there a way to add this to the Url-Object?

Greetings
matto
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:

If I understand you right: What will you use instead of "include(THEME_DIR_PHP.'news.php');"?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
matto
Jr. Bludit
Posts: 9
Joined: Fri Feb 19, 2016 6:50 pm

This is exact the code i am using.

It works fine, news.php is included, all code get executed.
The only thing is, bludit reports that it cannot build a news page, because there is none.

At the moment i am ignoring the error message, but i like to have a cleaner solution.
I want so bypass building a page object OR add a new location to the $Url Object, eg $Url->whereAmI() return news or custom or seomething similar.
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:

Shure, you have to add some code to a template news.php.

You can use for the condition a template or any code like for example:

Code: Select all

echo "Alert!";
What is the idea of bypassing $Url? Do you have an example?

And can you please give the address of your installation?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Post Reply