Creating the landing page

Some time ago I already wanted to begin creating the actual blog page (which I will refer to as landing page as it’s most likely the first page a visitor will see), but had to drop on that because there were some parts missing, first of all the settings, which again lead me to error-handling.

As of now I feel ready to start creating the landing page and so I opened up my editor with a new file index.php. Writing some lines I lost myself in reading some blog-posts about HTML5, sometimes it’s just better to re-read some stuff before diving head first into writing some new code…

Ok, so what’s to be happening on the landing page?
– Parts of the page should be displayed according to the settings (e.g. title)
– The user should be able to switch the languages
– The articles should be displayed (obvious)
– Categories should be displayed
– additional links should be displayed
– a footer should be visible

Displaying the page according to the settings
As the settings can be displayed and changed in the admin-panel all we need here is already in existence, so I can start writing right away.
First I’ll fetch the settings from the database using the getSettings-function. As of now the settings are not sorted or somehow organized by name in the array returned by that function, so I’m (for now) going to iterate over that settings array and explicitly check for the setting names and save each of them to a dedicated variable… this might should get changed in the future as it’s ugly, hardcoded and therefore not easy to maintain.
For now there are only three settings in use, which are title, subtitle and default language. Title will be used both for the browser title and the main-title in the HTML5 header-element, subtitle is also used in the header-element.

Switching languages
The user can switch from one language to another simply by clicking the respective language entry in the header-navigation, so the page should be able to display the articles in the selected language.
Upon startup the default language will be fetched from the settings and all articles with content for that language will be retrieved from the database and displayed in the main-section of the page.
I introduced a new function getArticlesForLanguage to the Connection-class which is used just for this part. Right now the function first gets all articles (using the getArticles function) and afterwards fetches for each of those articles the content for the currently selected language (if any is in existence).
This is surely not the best approach, as all articles are fetched and passed to the page where the final selection which articles will be displayed is performed by checking if there is any content given.
Worst case scenario: Plenty of data is fetched from the database and returned to the page but none is displayed as no article has content for the selected language.
This went straight to my ToDo-List as I’m planning on fetching only the articles that will be displayed and falling back to default language if an article has no content for the selected language but for the default language.

Displaying the categories
The categories are somewhat not directly related to the content, so they will be placed inside of an aside-element and should be displayed somewhere most likely on the right end of the screen.
Retrieving the categories is again nothing new as there already is the getCategories-function.
Each category will be added as a link inside of a nav-element in the aside-area.

Additional links and footer
As there are no additional links or any footer right now I’ll leave this one open for today.

So what does it look like right now?
Landing page, draft


Leave a Reply

*