Adding Blogs to the Sitemap using code

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 năm cách đây
Am trying to get all our blog entries added to the sitemap.xml as we're adding 2 or 3 a week.

Having read round - I have all the "commonsettings.sitemap  "

Have found the sitemap.cshtml file in /views/ and have looked at the existing code for products and categories and added my own for the blogs to try and get them all to be included in the sitemap.xml :


@if (Model.Blog.Count > 0)
        {
            <div class="entity">
                <div class="entity-title">
                    <h2>@T("Sitemap.Blog")</h2>
                </div>
                <div class="entity-body">
                    <ul>
                        @foreach (var product in Model.Blog)
                        {
                            <li><a href="@Url.RouteUrl("Blog", new { SeName = product.SeName })">@blog.Name</a></li>
                        }
                    </ul>
                </div>
            </div>
        }


I have tried both "blog" and "blogs" - but nothing appears in the sitemap.xml.

Any ideas?

I don't want to add another plugin - just code this directly into the view file.

I am not particularly technical - so this is about as far as my knowledge extends!

Thanks for any help.

Cheers
TW
7 năm cách đây
No one able to help?
7 năm cách đây
Hello,

Unfortunately, this is not possible by just adding code in the sitemap.cshtml. The SitemapModel doesn`t have the fields you are looking for. It only has a  "public bool BlogEnabled".
This means that the functionality you are trying to achieve is not available out of the box and you will have to customize the nopCommerce code.

I would like to turn your attention to CommonControler.cs ( located in ~/Presentation/Nop.Web/Controllers ). The SitemapModel is prepared on line 720.

Hope that helps!

Regards,
Anton
7 năm cách đây
Hi Anton,

One for the dev pile for NOP then as probably a quick win with minimal coding if I am going to be able to do it!

Seriously though - where is that folder ~/presentations you talk about as I can't find via FTP and I don't currently have root access on the server.

Sorry as said - not particularly technical.

Cheers
Will
7 năm cách đây
Hello Will,

Well, there are 2 "versions" of nopCommerce - source and no source. If you want to do customization to the nopCommerce source code you will need to use the source version. If you are using the no source version you will not have access to the file I was talking about.

You can download the nopCommerce source version from here. It is the second download link that is 101mb.

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