Project

General

Profile

Html element id

Added by Jagadees S over 7 years ago

Hi,

I created a WTemplate and called following function.

t->setTemplateText(\"

${myheader}

\");

everything is fine except the id. The id is missing in the output.

What i have to do to get a result like this:

....

Thanks,

Jagadees


Replies (4)

RE: Html element id - Added by Jagadees S over 7 years ago

Thanks Bruce.

When tried setId(), it created another div over the header:

...

Will it have any effect SEO or HTML standards?

RE: Html element id - Added by Bruce Toll over 7 years ago

Hi,

I have not tested this, but you should be able to set a custom tag for WTemplate, such as "header", by calling setHtmlTagName(), see: https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WWebWidget.html#adf6034e0e715138cae479eae6e324ce6.

You should then be able to set the WTemplate's class with setStyleClass("site-header") and set the role attribute with setAttributeValue("role", "banner"). Of course, the contents of your WTemplate text will need to be adjusted accordingly.

RE: Html element id - Added by Jagadees S over 7 years ago

Thanks Bruce.

I found another solution, as implemented in wt-home example.

call messageResourceBundle().use(appRoot() + "home", false); where home is the resource xml file.

in the xml file create a message with required template.

${neritam-header}

and when creating the WTemplate, pass the id of the message like:

WTemplate *t = new WTemplate(WString::tr("template"), root());

Now its creating exactly what i want.

As you said id is special in wt. but at the time of creation if we can give a unique id, then it will use that id.

Anyway, thanks Bruce.

Regards,

Jagadees.

    (1-4/4)