line break at first space in category name

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
where and how to add line break in category name. I would like the category name output to break at the first space it encounters. Anyone know how to achieve this? thanks.
6 years ago
azafnop wrote:
I would like the category name output to break at the first space it encounters.


For the first space line breaks need some customization or you can handle it using jquey.

Alternate way is to use HTML tag instead of space.

For example: Computers <br> This is by Divyang

Go to Nop.Web > Views > Catalog > TopMenu.cshtml

And change this line:

<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@category.Name


To

<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@Html.Raw(category.Name)


Hope this helps!
6 years ago
thanks for the response although
<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@Html.Raw(category.Name)
did not work.
6 years ago
azafnop wrote:
thanks for the response although
<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@Html.Raw(category.Name)
did not work.


Okay, can you please let me know what you have set your category name?
6 years ago
Hi,

I am looking for the same solution on my site.  I need the category names in my top navigation to display over two lines.

I tried replacing what you said in the Top Menu CSHTML file, but that did not do anything.

Please advise if there is another way to do this.

Thanks
Lena
6 years ago
Lena Raman wrote:
I tried replacing what you said in the Top Menu CSHTML file, but that did not do anything.


Hi Lena,

Please provide proper information with code change and mention if you're using any third party plugin or theme.
I've tested it in default theme, and it's working fine!
6 years ago
Hi,

I replaced <a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@category.Name

with

<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@Html.Raw(category.Name)

I am using a template with plugins (Lighthouse Theme from nop Templates).  there are a few plugins that I am using as well.

Will that solution not work if I am using third party themes and plugins?

Thanks
Lena
6 years ago
Upper solution doesn't work with first space!
It's working with HTML tag, if you want to display category name, you need to write category name with <br> tag.

For instance:  

Apple <br> Computers

Will display:
  
Apple
Computers

Lena Raman wrote:

Will that solution not work if I am using third party themes and plugins?


If they override TopMenu.cshtml page.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.