Dynamic sub nav - php

Ive created a portfolio website for myself, there is a gallery which users can enter, click on a thumbnail and then go to a new html page with the full image and description. Now on this full image page i have a list of other fullimage pages for project 2,3,4,5, etc..
But obviously manually updating project2.html to have a list of all other projects minius project 2 in the sub nav is very tedious and mistakes will occus when i have to do it for all 12 plus pages. So im after the page people are viewing not to appear in that sub nav.
My problem is.. Do i scrap the custom html site and move onto a cms.. The logical step for this sort of dynamic nav. Or do i try and include php if possible. Can anyone suggest the best approach for this, im aware it might in the longrun be easier to run off a cms but i do like the control i get and knowledge i hand crafted my html.
Thanks
Mat

If you wanted to do this with php, you could do so by making a single file containing the navigation, for example nav.html:
Project 1
Project 2
Project 3
all the project pages would then need to be php files, with the appropriate .php extension, and in each of them you would have:
<p>All your normal page html about the project and such that's above your navigation</p>
<?php
include("nav.html");
?>
<p>Anything underneath your navigation</p>
Alternatively, the CMS is a viable choice, or if you particularly fancied learning some php, you could actually code a perfectly servicable system to do this without too much trouble yourself.

If your don't want to use CMS , you can create a php file to handle requests for example , a php file that receive this request :
http://myfolio.com/moreinfo.php?album_id=1&
now in the php file you can get informatin from DB and folders then create a HTML Stream and then output it.

Related

Should I add home page HTML in wp classic editor or front-page.php for speed?

The title basically says it. I currently have my home page with the HTML sitting in the classic editor box. Should I move that to front-page.php? I know that it doesn't REALLY matter, and it won't have a huge impact, but I am being meticulous about creating a speedy website. So which is faster?
Also, I am currently using 2 separate PHP files for headers. One on the home page, and one for the rest. Should I just hard code the header for the home page into the same place as the home page HTML since it's the only page that uses it?
I'm pretty new to PHP, but I've searched Google extensively and can't seem to find my answer. Using WordPress. Really appreciate your help!
For speeding up the website, no need to change the home page or the header file. please do the following things for speeding up the website
Optimise your images
Enable caching
Enable GZIP compression
Minify CSS, HTML & JS files
Update plugins
Clean-up your database
Moving the html code to a template file will improve the site speed because WordPress will not have to retrieve those html tags from the database. And it is conventional and actually a good practice to place all rendering code (html, css, js) to the template or theme files where they should be, instead of directly adding them in the backend or instead of including them directly in the post editor.

How do I structure folders for users logged in and logged out?

I want the user's profile to show everything (logged in navbar, textbox they use to post their content on and all of their content) and then show their profile with a logged out navbar, selected content the user wants to show and no textbox to post content.
I am breaking up the html files (e.g. header, footer and main content) into separate php files. Is that a good idea if I want to implement the above said ?
I'm still developing on localhost but here's the current file structure which is a bit messy. I'm also trying to implement MVC but due to my lack of knowledge so far, it hasn't been done.
However you seem fit, but nice practice could be dividing up backend / frontend. Or have a public and a private directory as top layer, then go from there.
And yes, breaking up your files in header.php, *content.php and footer.php is smart for what you want. By doing this, you allow yourself to edit the main parts of you page independently, without having to update many html or php files. Just one file will do for every page.
Also google stuff like "common practice" for php structures.
Account for REST in your workflow How to create a RESTfull api
This Stackoverflow on html/php inlining is also usefull maybe.

how to create a multipage website

how can I develop a multipage website?
should I develop all other linked pages in same way I created the homepage?
I am intending to develop a PHP website for a store and I wanna link each products to their individual pages. but since there are lots of products its kinda tedious to create individual pages each product.
SO Instead of creating many different pages for each product can I create one dynamically changing page and use it for all the product links?I mean can I create a single page whose basic layout will always remain the same but only few content will change in accordance to the selected product.
Yes, you can do that; its very common to create a page that dynamically changes.
For example, you can create a php file that takes care of the header portion of the site, then simply call it within your index.php page as so:
<? show_header(); ?>
Take a look at this website to get started!
http://www.techiwarehouse.com/engine/d3bf2317/Building-Dynamic-Web-Pages-with-PHP
The site i provided is great to start playing with PHP, it provides good information with easy to follow steps.
Another great resource is the IBM PHP PDF:
http://www.ibm.com/developerworks/linux/tutorials/l-php/l-php-pdf.pdf
Finally my personal favorite, "Practical PHP & MySQL" PDF:
http://utopia.duth.gr/~stavtran/vivlia/PHP_and_MySQL.pdf
Its also worth noting that there are Content Management Systems out there (CMS) such as Joomla, Worpress which are very easy and powerful, a lot of these CMS's allow for plugins which will make your life so much easier. If your goal is to simply have a solid working e-commerce website that sells products and you don't really wish to do hardcore php,mysql,javascript,css,html,jquery coding ;-)
Content Management Systems
http://wordpress.org/
http://www.joomla.org/
You can implement a single page, lets call it product.php. Then you can use theGET method to dynamically call the page. It would look like this product.php?id=1 where id=1 is the primary key of the product in a MySQL table. And you could fetch various products just changing the id in url.
You can create multipage PHP website using following method:
1) Create a folder and name it “my_first_php_website”.
2) Create following folders in your “my_first_php_website” folder.
“images”, “includes”
3) Create following folders in “includes” folder.
“css”, “js”
4) Create following files in “my_first_php_website” folder.
-> “index.php”, “header.php”, “footer.php”, “sidebar.php”, “nav.php”, “404.php”, “about.php”, “functions.php”
Create following file in “css” folder.
-> “style.css”
Put your website logo in “images” folder.
-> “my_website_logo.png”
5) Now follow step by step tutorial to create your first website using PHP.
Source: Web Designer Tricks

PHP/MYSQL to create similar posts type script (similar images)

I am a beginner at using mysql/phpmyadmin, and have never used a cms before. I'm trying to get my head around how I could possibly add a 'similar posts' type script - but instead of showing posts, I would like to show some similar images (similar projects) when viewing each project page of my website.
My website setup is fairly simple:
main html page
profile html page
portfolio php page -> has thumbnail images with links to php generated url project pages
project page -> a dynamic php page that generates pages from pagination
contact html page.
The project php page has a jquery slideshow, project title and project overview text. The page uses three sql database tables for the data (slideshow images/text, page id for the pagination and one for normalisation), and uses pagination to change the data, creating a page for each project.
I'd really appreciate any ideas/opinions on how I could go about doing this - with sql, or am better off using a CMS (if so, do you know of a really simple one that could suit my website setup?).
If you're mainly wondering how you determine similarity, then you can do that with a text search in MySQL. I also found this page if you want to go to the trouble of building a tagging database schema. The former is simpler, but the latter is a really useful if you want to practice joins.

How to edit the files of an osCmax site

I have a website running on osCmax setup by a developer a while back and now I want to restyle some of the pages myself from the markup and CSS only.
I'm familiar with HTML/CSS and some jQuery to an extent but I have never touched any PHP. This is my first time really getting into any of the osCmax pages, site, etc., myself so I am little confused on what it really is or does.
If I want to edit any of the HTML/CSS myself for styling pages will I have to download and login to the osCmax admin panel to get to any of the files?
Or can I just go directly through my server to grab the appropriate HTML and CSS files? Wouldn't all the necessary files from the download be on my server already or is this something that I have to download to use?
If all you want to do is restyle the pages, then just modify the css. You shouldn't need to modify the PHP (unless parts of your HTML are created with out a class or id).
oscmax has a seperate folder for its template. all you have to do is editing the .css file. but sometimes you need to design the template from scrath and since the OSCMAX is outdated you must edit all the pages with .tmpl prefix.

Categories