Armadillo blog - how can I use Minicookie for Youtube videos in a blog entry?

I am using Minicookie stack on several sites. Now I would like to know whether it is possible to use the minicookie stack for blog entries?

I use the Armadillo blog. It would be nice if I could make sure that for Youtube videos posted in the blog the user first has to agree to be connected to YouTube. Outside of the blog I can place a minicookie stack for that purpose – but inside the blog?

Any ideas out there?

Thanks.
Franz

I hope to add this in a future free update.

For now, you could include your YouTube embed code within this PHP if / else statement:

<?php if (isset($_COOKIE["cookie_name_goes_here"])) {

  // Content the user has given consent to, like YouTube embed code

} else {

  // Optional message to show if the user has not given consent

} ?>

Replace cookie_name_goes_here with the actual name of your consent cookie.

Save it as a code snippet for future reference, if you find that easier.

When MiniCookie encounters this code, it will hide or show the content, depending on the presence of the consent cookie it sets.

Use as many of these as you want.

This works for any page type and most stacks, where you have the ability to enter custom HTML / PHP code.

4 Likes

Hi Will,

Many thanks for your quick response.

I tried putting the following into the body of the Armadillo blog but it did not work. I made the whole blog defunct by showing just a white page. I don’t know where else I could put the code. Can you please check whether I put the fill-in-texts in the right place?

<?php if (isset($_COOKIE[youtube_karten_cookies])) { // [https://youtu.be/x8uIhgx-bsM](https://youtu.be/x8uIhgx-bsM) } else { // Da Sie die Verwendung bestimmter Cookies nicht erlauben, kann das Video leider nicht dargestellt werden. Wenn Sie das Video doch sehen möchten, gehen Sie bitte zur Seite Datenschutz und klicken Sie auf den Button "YouTube erlauben". } ?>

Thanks.

Shalom,
Franz

Franz Rathmair | Mobil: +43 650 53 46 175 | Web: rathmair.eu

White screen probably means a PHP error.

I envisage you would enter this PHP code in your actual blog entries, in place of the normal YouTube embed code. The iFrame code then goes inside the first if statement.

Hi Will,

it does not work. When I put the PHP code into the blog entry window, it becomes a visible text when published. So, it seems to me, it is not recognized as php code but as text.

It is not a pressing issue, I will let it „simmer“ on the stove…

Shalom,
Franz

Franz Rathmair | Mobil: +43 650 53 46 175 | Web: rathmair.eu

Perhaps instead of reading and replying to these forum topics by email, it might make things a little easier for you to login properly to the forums using your web browser. You can access the RapidWeaver forums here in your normal web browser:

http://forums.realmacsoftware.com/

The code in your screenshot is radically different to the code I sent you. To be honest, I’m not surprised it doesn’t work for you. For starters, I do not see your YouTube iFrame code anywhere in there and your PHP comments include multiple lines.

Either you would use PHP to ‘echo’ the iFrame / alternative content into the webpage at that spot. Or split the code into multiple PHP blocks, with your HTML content written between, something like this:

<?php if (isset($_COOKIE["cookie_name_goes_here"])) { ?>

 <iframe width="560" height="315" src="https://www.youtube.com/embed/y0UG-pk15y0" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

<?php } else { ?>

  <p>This content comes from a third party. You have not given your consent to view this content. Please review your settings on my <a href="https://example.com">privacy policy page here</a>.</p>

<?php } ?>

If the PHP code is showing in your blog posts, it could be because Armadillo is not recognising it as correct PHP code, and is converting it to normal text.

Another possibility is that security settings in your blog don’t permit the use of PHP code in blog entries.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.