cookieconsent::initialize_widget (public)

 cookieconsent::initialize_widget [ -subsite_id subsite_id ]

Defined in packages/cookie-consent/tcl/cookie-consent-procs.tcl

Initialize an cookie-consent widget.

Switches:
-subsite_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 callback::subsite::page_plugin::impl::cookie-consent callback::subsite::page_plugin::impl::cookie-consent (public) cookieconsent::initialize_widget cookieconsent::initialize_widget callback::subsite::page_plugin::impl::cookie-consent->cookieconsent::initialize_widget ad_get_cookie ad_get_cookie (public) cookieconsent::initialize_widget->ad_get_cookie

Testcases:
No testcase defined.
Source code:
        if {[catch {ns_conn content}]} {
            #
            # If the connection is already closed, do nothing.
            #
            # "ns_conn content" will raise an exception, when the
            # connection is already closed. This is not obivous
            # without deeper knowledge. Therefore, NaviServer needs
            # probably a "ns_conn closed" flag the check for such
            # situations in a more self-expanatory way.
            #
            return
        }

        if {$subsite_id eq ""} {
            set subsite_id [get_relevant_subsite]
        }

        set enabled_p [parameter::get  -package_id $subsite_id  -parameter CookieConsentEnabled  -default 0]
        #
        # Just do real initialization, when the cookie is NOT set.
        # When more complex interactions are defined, this has to be
        # reconsidered.
        #
        set cookie_set [ad_get_cookie "cookieconsent_status-$subsite_id" ""]

        if {$enabled_p && $cookie_set eq ""} {
            #
            # Create an instance of the consent widget class from all configuration options
            #
            foreach {param default} {
                Layout         block
                Palette        oacs
                Position       bottom
                LearnMoreLink  https://cookiesandyou.com/
                DefaultPalette "popup {text #fff background #004570} button {text #000 background #f1d600}"
            } {
                set p($param) [parameter::get  -package_id $subsite_id  -parameter CookieConsent$param  -default $default]
            }

            set c [CookieConsent new  -subsite_id      $subsite_id  -position        $p(Position)  -palette         $p(Palette)  -layout          $p(Layout)  -learn-more-link $p(LearnMoreLink)  -default-palette $p(DefaultPalette)  ]
            #
            # ... and add it to the page
            #
            add_to_page -version "" $c
            $c destroy
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: