9 Replies - 508 Views - Last Post: 01 December 2012 - 03:19 PM

#1 -Nix-  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-December 11

How do i compact my HTML code.

Posted 30 November 2012 - 09:09 AM

So basically i have a toolbar that uses some javascript and a css file. I have the thing written in html. Can i put all of the html code for it into a (for lack of better terms) "variable". This way i can just call the variable where ever i want the toolbar instead of having to hundred lines of html into each webpage on my site?
Is This A Good Question/Topic? 0
  • +

Replies To: How do i compact my HTML code.

#2 Kruithne  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 99
  • View blog
  • Posts: 439
  • Joined: 28-July 09

Re: How do i compact my HTML code.

Posted 30 November 2012 - 09:25 AM

Hello there,

I think I understand your request but I might be mistaken, so I apologize in advance if I'm talking lemons while you want oranges.

I think the best way for you to achieve this is to look into a server-side language such as PHP. You would then have a basic 'layout' for each page, stored in one file, which includes the navigation that will show on every page. Then for each separate page, you just have the content that is different in a file, and include it.

If you really want to get into it, look up using framework structures such as MVC.
Was This Post Helpful? 0
  • +
  • -

#3 -Nix-  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-December 11

Re: How do i compact my HTML code.

Posted 30 November 2012 - 09:59 AM

I considered it, but the issue is that its already been written, and its alot of code. I was put on the job to modify it, and i dont know PHP. Im on a deadline
Was This Post Helpful? 0
  • +
  • -

#4 Kruithne  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 99
  • View blog
  • Posts: 439
  • Joined: 28-July 09

Re: How do i compact my HTML code.

Posted 30 November 2012 - 10:01 AM

Well, you've either got to use something like PHP or there isn't really a way (not that I can think of at least). It's HTML, it's a markup language, it's not advanced enough for file including and such just like that.

Regarding the deadline, learning PHP on a level high enough to include files that contain only PHP should not take more than a day. Look on a site like this or Tizag for quick crash courses in it.
Was This Post Helpful? 0
  • +
  • -

#5 -Nix-  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-December 11

Re: How do i compact my HTML code.

Posted 30 November 2012 - 10:01 AM

<div id="myjquerymenu" class="jquerycssmenu">
<ul>


<li><a href="#">Home</a></li>




<li><a href="#">Programs & Services</a>
  <ul>
  
  <li><a href="#">Communicable Diseases</a>
    <ul>
    <li><a href="#">MRSA</a></li>
    <li><a href="#">ABC's of Reporting</a></li>
    <li><a href="#">CDC Fact Sheets</a></li>
    <li><a href="#">World Health Organization</a></li>  
    <li><a href="#">Tuberculosis</a></li>
    <li><a href="#">Hand Hygiene</a></li>
    </ul>
  </li>
  
  <li><a href="#">Emergency Preparedness</a>
    <ul>
    <li><a href="#">Pandemic Influenza</a>
      <ul>
      <li><a href="#">Local Plan</a></li>
      <li><a href="#">U.S. Government</a></li>
      <li><a href="#">Ohio Pandemic Planning</a></li>
      </ul>
    </li>  
    <li><a href="#">Homeland Security Threat Advisory System</a></li>
    <li><a href="#">Emergency Response Plans</a></li>    
    </ul>
  </li>

  <li><a href="#">Environmental Health</a>
    <ul>
    
    <li><a href="#">Food Service Operations</a>
      <ul>
      <li><a href="#">Food Establishment Inspections</a></li>
      <li><a href="#">Temporary FSO/RFE Packet</a></li>      
      </ul>
    </li>
    
    <li><a href="#">Household Sewage Treatment Systems</a>
      <ul>
      <li><a href="#">Real Estate Inspection Printable Form</a></li>
      <li><a href="#">Richey Road Information</a></li>
      </ul>
    </li>

    <li><a href="#">Additional Programs</a>
      <ul>
      <li><a href="#">Campgrounds</a>
      <li><a href="#">Licensing & Service Fees</a> 
      <li><a href="#">School Environment Inspections</a> 
      <li><a href="#">Solid & Infectious Waste Facilities</a> 
      <li><a href="#">Tattoo & Body Piercing Establishments</a> 
      <li><a href="#">Indoor Environment</a> 
      <li><a href="#">Mold</a> 
      <li><a href="#">Ticks</a>       
      </ul>
    </li>
    <li><a href="#">Nuisance Complaints</a></li>
    <li><a href="#">Private Water Systems</a></li>
    <li><a href="#">Public Swimming Pools</a></li>
    <li><a href="#">Manufactured Home Parks</a></li>
    <li><a href="#">West Nile Virus</a></li>
    <li><a href="#">Rabies Prevention</a></li>
    </ul>
  </li>



  <li><a href="#">Immunizations</a>
  <ul>
    <li><a href="#">General Information</a></li>
    <li><a href="#">Clinic Schedule</a></li>
    <li><a href="#">Travel Requirements</a></li>
    <li><a href="#">Flu Vaccine</a></li>    
  </ul>
  </li>
 
  <li><a href="#">Infants & Children</a>
  <ul>
  <li><a href="#">Bureau for Children with Medical Handicaps</a></li>  
  <li><a href="#">Car Seat Program</a></li>
  <li><a href="#">Child Fatality</a></li>
  <li><a href="#">Help Me Grow</a>
    <ul>
    <li><a href="#">Newborn Home Visits</a>
      <ul>
      <li><a href="#">Back To Sleep</a></li>
      </ul>
    </li> 
    <li><a href="#">Prenatal Visits</a></li>   
    </ul>
  </li>
  <li><a href="#">School Health</a></li>
  <li><a href="#">SIDS Support</a></li>
  </ul> 
  </li>

  <li><a href="#">Medical Reserve Corps</a>
    <ul>
    <li><a href="#">Application Form</a></li>
    <li><a href="#">Serve Ohio</a></li>
    <li><a href="#">National Medical Reserve Corps</a></li>
    </ul>
  </li>
  
  <li><a href="#">Vital Statistics</a>
  <ul>
    <li><a href="#">Birth & Death Records</a></li>
    <li><a href="#">Genealogy</a></li> 
    <li><a href="#">Paternity Formss</a></li>   
  </ul>
  </li>

  <li><a href="#">STD Clinic</a></li>

  <li><a href="#">Links</a></li>
  </ul>



<li><a href="#">Divisions</a>
  <ul>
  <li><a href="#">Environmental Health</a></li>
  <li><a href="#">Nursing</a></li>
  <li><a href="#">Vital Statistics</a></li>
  <li><a href="#">Emergency Preparedness</a></li>
  </ul>
</li>

<li><a href="#">About Us</a>
  <ul>
  <li><a href="#">Mission Statement</a></li>
  <li><a href="#">Board of Health</a></li>
  <li><a href="#">Staff</a></li>
  <li><a href="#">Privacy Statement</a></li>
  <li><a href="#">Annual Report</a></li>
  </ul>
</li>

<li><a href="#">Contact Us</a>
  <ul>
  <li><a href="#">General Information</a></li>
  <li><a href="#">Area Map</a></li>
  </ul>
</li>

<li><a href="#">Employee Email</a></li>


</ul>

</div>



I want that put into a small piece of code so i can just call something like <toolbar> and it just implements all that code. And have that "<toolbar>" reference a file that i can edit so it applies to all the pages.
Was This Post Helpful? 0
  • +
  • -

#6 Kruithne  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 99
  • View blog
  • Posts: 439
  • Joined: 28-July 09

Re: How do i compact my HTML code.

Posted 30 November 2012 - 10:02 AM

Sorry, HTML does not do that. You will need PHP or another server side language. (Or bad use of Javascript, but that's bad to do, so don't).
Was This Post Helpful? 0
  • +
  • -

#7 -Nix-  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-December 11

Re: How do i compact my HTML code.

Posted 30 November 2012 - 10:11 AM

So in my position, would the best thing to do be copy it to every DIV on all the pages?
Was This Post Helpful? 0
  • +
  • -

#8 Kruithne  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 99
  • View blog
  • Posts: 439
  • Joined: 28-July 09

Re: How do i compact my HTML code.

Posted 30 November 2012 - 10:17 AM

In your position, I would suggest that you take an hour or so to learn the very basics of PHP and then look at the include function. All you will need is that single function and you will be able to achieve what you are after.

Failing that, you will just have to include all of the navigation and layout on each page.
Was This Post Helpful? 0
  • +
  • -

#9 no2pencil  Icon User is online

  • Head MFIC
  • member icon

Reputation: 5072
  • View blog
  • Posts: 26,460
  • Joined: 10-May 07

Re: How do i compact my HTML code.

Posted 30 November 2012 - 10:23 AM

Can you write the code in jquery? Then you can write the code into a function, & call it within the page. If you need it on more than one page, include it in a footer.php like Kruithne suggested.

HTML code is client side, so it offers little dynamic functionality.
Was This Post Helpful? 0
  • +
  • -

#10 goku87  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 73
  • Joined: 17-October 09

Re: How do i compact my HTML code.

Posted 01 December 2012 - 03:19 PM

View Post-Nix-, on 30 November 2012 - 10:01 AM, said:

I want that put into a small piece of code so i can just call something like <toolbar> and it just implements all that code. And have that "<toolbar>" reference a file that i can edit so it applies to all the pages.


To answer your question, do this:
  • Copy/paste your code into a separate file, such as toolbar.html
  • Wherever you need the "toolbar" on a page, simply linclude the file with PHP like so: <?php include('toolbar.html');?>
  • PHP is a "directory-sensitive" scripting language, so if your including file isn't in the current directory with the page that is trying to include, it will return an error. The easiest way to prevent this is to throw your file in the root directory, and precede with the directory-equivalent to the root foolder, aka "./" so it might look something like './toolbar.html', but this is presuming apache's root folder is the same as the root directory for your site.
    And just for future reference for when you start learning PHP, if you have any PHP coding within the included file, it must be a *.php file rather than an *.html file.
  • Go here: http://w3schools.com/php/
  • Finish the basic section as payment for giving you your answer. I gave you a fish, but I'm also trying to help you learn out to fish as well.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1