Сan`t replace span to <h> in TopicPage

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 14 ans
Hello,
I can not replace <span> (Label) in Topic Page
When created some topic in version 1.20 i got source
[quote]
<div class="htmlcontent-title">
<span id="ctl00_ctl00_cph1_cph1_ctrlHomePageText_topicHomePageText_lblTitle">My Home Page</span>
</div>
[/quote]
Question. Where it create tag <span>? (in code Modules/TopicPage we can see <asp:Label>)
How can i change to <h>?
Thanks
Il y a 14 ans
Hi..
in fact that <asp:label> control create that <span> tag.

if you want to modify ASP.NET control so it produces exactly the HTML you want, you can use "control adapters"

[quote]These are little chunks of logic that you add to your web site to effectively "adapt" an ASP.NET control to render the HTML you prefer.[/quote]

but i don't think it's a good idea for your problem.(because i don't know how can i do that ;) )

so you can just replace:(line #6)

<asp:label runat="server" id="lblTitle"></asp:label>

with:

<h3 runat="server" id="h3Title"></h3>


and in code behind change (line #51)

lblTitle.Text = localizedTopic.Title;

to:

h3Title.InnerText = localizedTopic.Title;




and if you just change this for appearance, i suggest that you work with css.
or you can wrap label control with <h#> tag in .ascx file
<h3><asp:label runat="server" id="lblTitle"></asp:label></h3>
Il y a 14 ans
I tried this example yesterday
[quote]
<h3><asp:label runat="server" id="lblTitle"></asp:label></h3>
[/quote]
It`s not work.
I got:
[quote]
<span id="ctl00_ctl00_cph1_cph1_ctrlHomePageText_topicHomePageText_lblTitle">My Home Page</span>
[/quote]
Instead
[quote]
<h3><span id="ctl00_ctl00_cph1_cph1_ctrlHomePageText_topicHomePageText_lblTitle">My Home Page</span></h3>
[/quote]
Also this code not clear for spiders ;)
This code with literal
[quote]
<h3><asp:literal runat="server" id="lblTitle"></asp:literal></h3>
[/quote]
Convert also to:
[quote]
<span id="ctl00_ctl00_cph1_cph1_ctrlHomePageText_topicHomePageText_lblTitle">My Home Page</span>
[/quote]
If so,
[quote]
<h3 runat="server" id="h3Title"></h3>
[/quote]
with these codes will be the same.

But I will try a little later
Thx
Il y a 14 ans
thanks for "spider" tip.

i have a same problem until i realize that there are 2 module for manage topics.
topic.ascx and topicPage.ascx.
built in topic such as "about us" use topic.aspx based on "TopicName" and "ViewState". and others that represent through topic.aspx use topicPage.ascx depend on "TopicID" and "QueryString".(i think)
Il y a 14 ans
alexlin wrote:

[quote]
<h3><span id="ctl00_ctl00_cph1_cph1_ctrlHomePageText_topicHomePageText_lblTitle">My Home Page</span></h3>

Also this code not clear for spiders ;)
This code with literal
[/quote]

Where did you get this nonsense? Spiders are much cleverer than you think. Just leave this span and spiders will ignore it just fine.
Il y a 14 ans
[quote]
<h3 runat="server" id="h3Title"></h3>
[/quote]
It`s not work.
When i added <h1> into body, it`s work
but i sure what place of Title in topic (Administration) later must be <h#> on client.
Il y a 14 ans
You can replace the label control with a literal control then include any html you would like rendering when setting it's text property e.g. litMyTitle.Text = String.Format("<h1>{0}</h1>", localizedTopic.Title);
Il y a 14 ans
Hi,
It`s not work

[quote]
ltrTitle.Text = String.Format("<h1>{0}</h1>", localizedTopic.Title);
[/quote]

Anyway this create <span>
Il y a 14 ans
Hi,

Here's my implementation of the "Topic.ascx":
<div class="nop-content-title">
    <h1>
        <asp:Literal ID="litTitle" runat="server"></asp:Literal>        
    </h1>
</div>
<div class="nop-container">
    <div class="nop-container-body">
        <asp:Literal ID="litBody" runat="server"></asp:Literal>
    </div>
</div>

You can ignore my css classes. The important part are the 2 literals - the first contained in h1 block and the second in a div (it must be a div)
and in the .cs file
            LocalizedTopic localizedTopic = TopicManager.GetLocalizedTopic(this.TopicName, NopContext.Current.WorkingLanguage.LanguageID);
            if (localizedTopic != null)
            {
                litTitle.Text = localizedTopic.Title;
                litBody.Text = localizedTopic.Body;
            }

Notice that in code i've updated the lblTitle and lblBody with the literals above.

Hope this helps (well it must because it works).
Il y a 14 ans
Hi,
Is it work properly?

What is html source code you get?

Thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.