Developer forum

Forum » Templates » Do not render cookie notice on a page

Do not render cookie notice on a page

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Is there a way to prevent the cookie warning from being rendered on a particular page?
(using DW9.14 and Swift 1.12 - not that it matters)

 

We're using a page to render as pdf and store to disk through a notification. Because that's not running on the same session of the user, it's rendering the cookie warning. Short of moving that page to a dummy area just to disable the cookie warning from rendering, can I do this at the template level (or some page property I might not be aware of; or by changing something on the Area/Page Model)?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

if pdf=true, do not render cookie banner?

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

In this case, it's using the PDF method, not even doing pdf=true. I may be wrong thinking this should be fixed in the template. Here is our code

 

public static void GenerateCertificationForm(Order order)
{
    if(order is null 
        || !order.Complete 
        || order.CheckoutPageId.Equals(0))
    {
        return;
    }

    var certificationFormPathField = order.OrderFieldValues.GetOrderFieldValue(Constants.OrderFields.OrderCertificationFormPath);

    if(certificationFormPathField is null)
    {
        return;
    }
        
    var checkoutPage = Dynamicweb.Services.Pages.GetPage(order.CheckoutPageId);

    if(checkoutPage is null)
    {
        return;
    }

    var formCertificationPage = Dynamicweb.Services.Pages.GetPageByNavigationTag(checkoutPage.AreaId, Constants.Miscellaneous.FormNavigationTag);

    if(formCertificationPage is null)
    {
        return;
    }

    var url = string.Concat(Dynamicweb.Context.Current.Request.Url.Scheme, "://", Dynamicweb.Context.Current.Request.Url.Host);
    url += Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(formCertificationPage.ID);
    var pid = Dynamicweb.Services.Paragraphs.GetParagraphsByPageId(formCertificationPage.ID).FirstOrDefault(p => p.ModuleSystemName.Equals("eCom_CustomerCenter") && p.ShowParagraph)?.ID ?? 0;

    if (pid > 0)
    {
        url += $"?CC{pid}=Order&OrderID={order.Id}";
    }

    var user = Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser();

    try
    {
        var pdf = new Pdf(url, user?.UserName ?? string.Empty, user?.DecryptedPassword ?? string.Empty, false, false, 15, 15, Pdf.GetPaperSizeValue(SystemConfiguration.Instance.GetValue(" /Globalsettings/Settings/Pdf/PageSize")));
        var folderPath = $"/Files/Files/CommonwealthCharterAcademy/OrderCertificationForms";
        var pdfFilePath = $"{folderPath}/{order.Id}_Certification_Form.pdf";
        var pdfFileServerPath = Dynamicweb.Core.SystemInformation.MapPath(pdfFilePath);
        System.IO.Directory.CreateDirectory(Dynamicweb.Core.SystemInformation.MapPath(folderPath));
        pdf.SaveToFile(pdfFileServerPath);
        pdf.Dispose();
        certificationFormPathField.Value = pdfFileServerPath;
        Dynamicweb.Ecommerce.Services.Orders.Save(order);
    }
    catch(Exception ex)
    {
        OrderDebuggingInfo.Save(order, ex.Message + ". " + ex.InnerException, "OrderCertificationForm");
    }
}

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Seems like you send in a URL.

Then add ?mycustompdf=true and test for that...

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

I see where you're going with this. We will try it out, thanks

 

You must be logged in to post in the forum