Developer forum

Forum » Rapido » Replace a block on Masterpage

Replace a block on Masterpage

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am trying to replace a block in the MasterpageFooterContent.

I have tried to follow the guidelines in the documentation but whatever I do, it does not seem to replace the block.

I am probably doing something wrong.

Considering that I am using a standard Rapido with DW 9.6.3 and I am trying to replace the block for the first colum in the footer, here is my code:

@{
  BlocksPage masterBlocksBlocksPage = BlocksPage.GetBlockPage("Master");
  Block masterFooterColumnOneCustom = new Block
  {
   Id = "MasterFooterColumnOne",
   SortId = 10,
   Template = RenderFooterColumnCustom(footerColumnOneHeader, footerColumnOneContent)
  };
   masterBlocksBlocksPage.ReplaceBlock(masterFooterColumnOneCustom);
}

What am I doing wrong?

Thank you,
Adrian


Replies

 
Karsten Thuen Dynamicweb Employee
Karsten Thuen
Reply

Hi Adrian

Thank you for writing. I have tested your setup, and sadly I found a small bug in the Master template on Rapido 3.1 

It has this new code, that tests if the custom blocks file for the master exists:

@if (File.Exists(HttpContext.Current.Server.MapPath("/MasterBlocks/Custom__Blocks.cshtml")))
{
    <text>@Include("MasterBlocks/Custom__Blocks.cshtml")</text>
}

It should have been:

@if (File.Exists(HttpContext.Current.Server.MapPath("/Files/Templates/Designs/Rapido/MasterBlocks/Custom__Blocks.cshtml")))
{
    <text>@Include("MasterBlocks/Custom__Blocks.cshtml")</text>
}

 

I will secure that this will be in the next hot-fix release, and carefully go through all the Custom__Blocks.cshtml references. Until then, you can safely fix it by replacing the broken code.

 

Best regards
Karsten Thuen

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Karsten,

Thank you very much for the update.

I will fix the code.

Thank you,
Adrian

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Karsten,

You probably have noticed it already but I found the same issue with a different include on another file.
On cleanlayout.cshtml the check to include the file Components/Custom/Custom__Components.cshtml is also missing /Files/Templates/Designs/Rapido from the MapPath method.

Thanks,
BR, Mario

 

You must be logged in to post in the forum