Creating Common Headers and Footers

3 replies · opened Oct 30, 2016

VvanbennoOct 30, 2016

I know that I would be best off actually 'learning' how to do this but I can't find a suitable answer using the search tool. I have created a website using your template (no prior web development experience) and I am interested in being able to have the headers and footers of each page be common so that I don't have to copy/paste the text 27 times whenever a change is implemented. I'm sure that this is possible using jquery or JS but I have no working knowledge of those technologies. I'm usually good at figuring out puzzles but I could use a boost this time.

Thank you in advance!
-Van

P.S. Here is the live link
https://d2kpejp8x5bq63.cloudfront.net/

SSemicolon WebSTAFFNov 2, 2016

Hello,

Thank You so much for using Canvas! :)

This is Definitely Possible but it is more recommended to use the PHP include() Functionality for this. Simply add the Menu Code into a File with a .php extension and then include it in all your Files. Now, you will simply need to change the Menu Links in that include file and then all the Files will have an Updated Menu. Make sure that you change your File's Extension from .html to .php .

You code will look something like this:


	

		...

		

	

This will definitely work fine. Let us know if we can help you with anything else or if you find any other issues.

VvanbennoNov 4, 2016

Even though I don't know (or have any desire to learn such a broken and antiquated scripting language) PHP, your team has done all the work so I can just add the scripting cited above and it should work?

My colleagues really loathe PHP for several dozens of reasons and have warned me to stay away from it because there's dozens of better and faster languages available today. I'm told as an exaggerated example that you could sit and write out 2,000 lines of code to complete a function that would be about 20 lines of code in something like NODE.js.

If I copy / paste the solution posted it'll just work? It's not going to make the site load differently?
Thank you for helping me out, though! If it's a core part of the functionality of the template then I'll just throw it in and take it as the easiest solution. Thank you very much!

SSemicolon WebSTAFFNov 6, 2016

Hello,

PHP is the most commonly used Language and easy to Pick up. You can definitely consider using Ruby, however, you will need intermediate/advanced modifications to make this work correctly.

Regarding the Solution provided above, you will first need to move the Menu HTML Codes inside the PHP Include File with your desired name and then add the above mentioned codes accordingly. More details on this can be found here: http://php.net/manual/en/function.include.php .

Here is a more Detailed Example for this: http://www.apaddedcell.com/how-automatically-include-your-header-navigation-and-footer-every-page .

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard