XHTML template programming - xhtml

Its been a while since I've done any hard core web design, so I have a question for you. I'm pretty sure that there is a feature of xhtml that allows you to create a template and include that template in your other xhtml pages. What I'm trying to do is create a "main links" template that allows any page to reference the main pages of the site. I figured a template would be better to use as it would allow easy editing of those links. If I were to just hard code them on all the pages, that would be a nightmare if I had to change something.
Btw, this site is only being done in xhtml, css and javascript. I could have used something more beefy like jsf, but I just didn't feel like it.
If anyone has any ideas on this, or suggestions on a better way to do it, it would be great.
Thanks,
Robbie

You're probably looking at doing something with includes, which isn't a part of XHTML but rather a server-side technology such as PHP or ASP.
See this W3School's articles on PHP include() and require() and ASP Including files.
As far as I know, there isn't anything in XHTML, CSS and/or JavaScript that does what you want.

You could extend the DTD with entities (as described at http://xml.silmaril.ie/authors/includes/) but you'll find browser support as poor as it is for XInclude.
If you want to use any kind of templating, then you need to look to other technologies which you can set up to output XHTML rather then doing anything intrinsic to XHTML itself (at least if you want to approach the problem sanely).
http://allmyfaqs.net/faq.pl?Include_one_file_in_another is a good summary of the options available.

Do you mean something like asp.net master pages?
You can use AJAX or Serverside includes to include parts of your template. However, XHTML does not support this by default. You have to write code yourself. Most websites have a template which is included serverside.
In php you can do this:
page.php
<?php ob_start(); ?>
your page
<?php
$content = ob_get_contents();
ob_end_clean();
$title="pagetitle";
require("template.php");
?>
template.php
Use <?php echo $title; ?> where you want your title
Use <?php echo $content; ?> where you want your content

If you really want to stay away from server side technologies that can offer the include functionality you want, perhaps you can find an IDE / editor that supports templates or includes or something similar. I have no experience with this myself, so I cannot recommend specific software, but I know that there are IDEs / editors that offer the functionality you look for.

Related

Kentico CSS issue

I am using Kentico and have noticed a weird css issue. After mocking my pages up in Dreamweaver I then create the page in Kentico, however I have noticed that some elements in Kentico are slightly misaligned.
I have tried copying the source from Kentico into Dreamweaver to see if I can fix the issue but Kentico still renders the content incorrectly.
Are you using Dreamweaver in design or split mode? if yes, turn it off and use code mode only.
I guess you have to compare structure of your HTML and Kentico output HTML. Kentico add a form tag by default which may cause structural issue with css. If you can provide both html, I can help
On Kentico (up to version 11) when you use portal engine or ASPX templates you have this shortcoming. Kentico adds excessive HTML markup on the controls it creates on order to provide hooks that will help the engine to perform actions. For example, Bizforms add multiple divs/spans around normal input tags. So, you have to adapt the CSS you have created to match the tags used by Kentico.
What is your template type:
ASPX page: You can copy your entire HTML code from Dreamweaver into your aspx page template and then work on your page.
Portal Page: You need to understand the structure and cannot replace entire HTML Code from Dreamweaver. You have to seperate your HTML code to insert DropZone for web parts and widgets.
Good Luck!
You will have to make some adaptation always from raw HTML and kentico. In your case you are using aspx model which makes it more harder as server level changes are not 100% compatible with raw HTML or client side code. If possible use portal engine with transformation which will be more like to like of raw HTML.
You must create a directory in CSS/Stylesheet
If you're using the CSS section of the Admin interface, check to see if you have any & signs at the beginning of any tags. Kentico doesn't seem to support this so might be breaking any classes that appear after it.

List all Twig templates used in the current request

I'm using Symfony2 with Twig templating engine.
Is there any way to output a list of all Twig templates files loaded in the current request, including the ones loaded through extends, include, etc.?
That would make my life much easier when overriding third-party bundles' blocks, but I can't find a way to do it.
I've been looking for such a tool for a long time but never found it... The debug options of twig are very limited, and there is no tool in the sf2 dev bar dedicated to it...
I always add twig or html comments on top of each of my templates to get an idea of where I am and why during development or on the final page.
You can try this code, it puts filenames in HTML like this:
<!-- START templatename.html.twig -->
...
<!-- END templatename.html.twig -->
I know, that it is not a good solution, but it is better than nothing.
not a problem when you are working in dev in app_dev.php
expand bottom SF toolbar, click on 200 status or on #your_rote_name
you will redirect to smt like localhost/_profiler/s0meha5h?panel=*
then click on left menu on TWIG then url will be like localhost/_profiler/s0meha5h?panel=twig
and you will see all templates like FolderYourBundle:Folder:twig_file_name.html.twig that loads one by one!

How to make same layout for all web pages

I am currently working on HTML I want to ask a question about website development.I am developing a website in which the basic layout remains same like menu, side menu etc but only the content changes.Currently I have make separate .html file for all web pages.
Can any one tell me is there a way through which I can make a separate file having etc common to all and call it in my html file.I have heard about CSS but it will only change the style and layout.
thanks
If your HTTP (apache 2 and IIS do) server supports Server Side Includes then you can just include another HTML file :
<!--#include file="header.html"-->
your content
<!--#include file="footer.html"-->
no need for a server side language then - just plain HTML
This is very big topic to include in just one answer. SO I will give only the logical part.
Separate your template into multiple chunks like:
1. header.php
2. leftSidebar.php
4. rightsidebar.php
5. footer.php
Now, include these common part on your every page.
For example: index.php
<?php
include "header.php";
include "leftSidebar.php";
echo "<div>".$thedifferentpart."</div>"; //Change only this part on every other page you will create.
include "footer.php";
?>
NOTE: This is only a logical part, applying the concept on your code
Yes, your best bet is a server side language, as Adam said. Absolutely avoid using the old style html frames: they're deprecated, and cause a certain number of problems, both on the programming side and on google optimization.
By using a server side language, you'll still have entire pages, but they will be partially generated by php (or asp) by printing more files into one. For example:
http://www.php.net/manual/en/function.include.php
Bye!
Your best bet in the long term is to use a server side language like ASP.net or PHP
I don't believe that is possible, strictly through HTML. However, you could use server side scripting like PHP to get it done. What you're talking about is a template, and is used quite often. What you would want, is to have your menu items (and CSS) and your header/footer code in separate pages. This way, if you make changes to the menu, or header/footer, it would be reflected in all the pages (written with PHP) you have scripted with the template method.
You would need the menu.html, header.html and footer.html in a place accessible by your main page code. That is, you would use the template method to write the content of your pages.
A psuedo code example in PHP would be like such:
<?php
include('header.html');
include('menu.html');
echo "Your main content items here";
include('footer.html');
?>

Uses of html classes aside from css

I am a total beginner so pls be patient with me if my question might sound too dumb.
I am studying html, css, basic native php, and cakephp at the same time (which is not a good idea, I think its better to master the native cakephp first before jumping to any framework). As far as I know classes and ids are for css styling until I stumbled upon this code when I am studying cakephp:
<div class="posts index">
.
.
.
</div>
Note: I scaffolded a Post
I tried to look in the default css of cakephp for the class "posts index" but I can't find it so I concluded that there may be other uses of html classes aside from css. I am not sure about. I am just guessing. Can somebody explain to me in general about html classes. I also wanna know about the class "posts index" regarding its significance to cakephp. Pls help...
first of all you have to separate your "business logic" (program logic) and your "view" (output). The logic is done by your php code, it doesn't matter whether you use a framework or not. Your output can be html, xml, wml or some other stuff and is generated by your logic, your php code.
-> The class definition is only relevant in your output, so it doesn't matter for your cakePHP!
Next, there's no syntactic rule that every class in html must be defined in css. So your conclusion uses a rule that does not exist :-) It is not nice code because you have unused and needles html code, but it is not wrong. Most frameworks and tools use such "default classes" because of template support. Look at the html code of wordpress templates, there you will find these classnames, too, to make it more easy to change your css files to get different look&feels. When you create a new template with css styles, you know that the "posts index" element contains post-entries...
You can use classes and ids in JavaScript to get and identify elements, but this belongs also to the output/client-side area.
BTW: if you parse your html with some php code and need the class definition to identify an html element in the DOM then it matters, but I don't think you want do this ^^

Drupal Cache & Stylesheet Switch

I'm using a very simple Stylesheet Switch by php. It was fine all along but days ago I turn on Caching mode and now it only work for login user. If turn off Caching mode, it will work again for both user.
Basically the code looks like this
In the page.php header
<?php
if(isset($_COOKIE['style'])){
$style=$_COOKIE['style'];
} else {
$style='green';
}
?>
<link type="text/css" rel="stylesheet" href="/css/<?php echo $style ?>.css">
It switch by
Blue
In the switch.php
<?php setcookie('style', $_GET['style'], time()+31536000);
header('Location:'.$HTTP_SERVER_VARS['HTTP_REFERER']);
?>
I did many research but couldn't find the right way. Please help if you can. Thank you
Hmm, I don't see why you can't just use a client-side style switcher, as in http://www.alistapart.com/articles/alternate/. There are other methods of doing it purely client-side, but it seems a bit overkill to request an entire new page to switch styles.
Also, caching creates a static page to serve up in lieu of dynamically creating a new page for every hit, so the cached page is probably getting served up to whoever isn't getting the style switching.
From my understanding/experience standard drupal caching is only for non-logged in users. There is at least one module that allows for authenticated user caching, but it's not in Core, authcache:
http://drupal.org/project/authcache
An old article that explains druapl caching techniques. Still has some good information in there: http://n0tablog.wordpress.com/2007/11/19/drupal-caching/

Resources