Sign in to follow this  

[web] Making new xhtml tags?

This topic is 4778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to define new tags for xhtml? I have heard it can be done with xml modules. Is there any other way, like css or something? I am wanting to define my own html tags to do certain stuff for my cms. Like <cms_block></cms_block> that sets up the block div and ends the block div. Has anyone even attempted this also? [Edited by - jumpjumpjump on November 13, 2004 2:31:00 PM]

Share this post


Link to post
Share on other sites
there are two ways to go about what you're thinking.

1. Use CSS to define the behavior/look of a tag. So you could have

code
{
display:block;
background-color:#ccc
}

that will make any <code></code> tags display as a block (like p tags) and have a gray background.

2. If you use an application server (ie. asp.net, php, coldfusion, etc), your CMS can store the specialized tags in the database. When it comes time to display your content, you can do a search and replace for your special tags and replace them with whatever you want.

-edit: also, if you put simply put special tags in your markup and use CSS to define their behavior, the page will not validate as xhtml. But if you don't care about that, then knock yourself out :-)
Hope that helps,

Share this post


Link to post
Share on other sites
I use XML to do something similar which is then transformed into XHTML using XSL and combined with a CSS stylesheet to do this sort of thing.

So in my CMS, I can type something like <newsfeed id="demo" /> and it'll place the newsfeed where needed. The XSLT will sort out the conversion into div tags and apply the right style.

Share this post


Link to post
Share on other sites
Would this work and validate and then define their behavior with css?
Edit: Something like this: http://www.w3.org/MarkUp/Guide/xhtml-m12n-tutorial/

Edit2:
joelmartinez: your site has sql injections: http://codecube.net/viewitem.asp?cc_catID=18&cc_typeID='4&catName=Code%20Bank

strip out the quotes and stuff before you perform your query.

Share this post


Link to post
Share on other sites
Quote:
Original post by jumpjumpjump
Would this work and validate and then define their behavior with css?
Edit: Something like this: http://www.w3.org/MarkUp/Guide/xhtml-m12n-tutorial/

Edit2:
joelmartinez: your site has sql injections: http://codecube.net/viewitem.asp?cc_catID=18&cc_typeID='4&catName=Code%20Bank

strip out the quotes and stuff before you perform your query.


ick injections

Share this post


Link to post
Share on other sites
You can't add new elements to XHTML, that would not be right.

But you could define your own namespace which is NOT XHTML, and stick elements belonging to that schema into xhtml documents, and style them with CSS.

BUT there's no reason that any particular browser should or would support that.

But they probably will.

Also, you could confuse older / simpler browsers because they might interpret those elements as HTML, which of course they would not be.

I suppose the right thing to do for an XHTML browser is to ignore elements from namespaces it doesn't know what to do with.

Mark

Share this post


Link to post
Share on other sites
No problem .

I'd recommend doing it using the CSS. This way you could go:

// HTML
<div id="good">This is good text!</div>

// CSS
#good {
font-size: small;
}

You could change the style to anything you want. When you change the CSS, it'll change globally. No need to worry about smarty at all.

Share this post


Link to post
Share on other sites
I know, but this is for a custom block template language for the block system in my CMS.
I want it to be like this so no0bs can make blocks.

<cmsblock>
<blocktitle>Title</blocktitle>
<blockcontent>
content wow
</blockcontent>
</cmsblock>



So I am going to just write a smarty plugin that will parse the template and return the template with the tags replaced with their html.

Share this post


Link to post
Share on other sites
My CMS looks like this:


== Wow, a Heading ==

Do something insanely cool here - like an http://www.gamedev.net autolink, anyone?

[code]
How about a custom source box?
[/code]

**How about bold?** \\Or Itallics?\\ \\**Or both?!"**\


You get the gist. I parse the content with regular expressions and generate XHTML from that. Not too tricky, really.

Share this post


Link to post
Share on other sites
I have it working. I call it block xml. ;)

Very easy todo, and it still works with my template system.
The function:

function parse_block($message) {
$preg = array(
'/(?<!\\\\)\<cms_block(?::\w+)?\>(.*?)\<\/cms_block(?::\w+)?\>/si' => "\n<table>\n<tr>\n<td>\\1</td>\n</tr>\n</table><br />",
'/(?<!\\\\)\<cms_block=(?::\w+)?(.*?)\>(.*?)\<\/cms_block(?::\w+)?\>/si' => "\n<table>\n<tr>\n<th>\\1</th>\n</tr>\n<tr>\n<td>\\2</td>\n</tr>\n</table><br />",
);
$message = preg_replace(array_keys($preg), array_values($preg), $message);
return $message;
}


and an example of what it looks like in the template:

<cms_block>
This is a simple block
there will be no title header,
just a border
</cms_block>
<!-- or for title/header -->
<cms_block=Title>
block contents
</cms_block>



That is all there is to it. BBcodes can also be made that way, but I am going to pull them from a database.

Share this post


Link to post
Share on other sites

This topic is 4778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this