Problem
There is no way for a site builder to remove the copyright or alter it. It can only be changed in the theme.

Solution
Create settings in the theme so site builders can toggle the copyright text on and off. There is default copyright text in the twig file, and users can also choose to set custom copyright text through the UI.

copyright settings form

By default the copyright text is toggled off.

Comments

tkoleary created an issue. See original summary.

oscarvargas102’s picture

Status: Needs work » Needs review
StatusFileSize
new3.21 KB
dabito’s picture

@oscarvargas102 Patch does not comply with Drupal coding standards, please correct!

samuel.mortenson’s picture

The patch also does not do what @tkoleary original suggested.

oscarvargas102’s picture

Drupal coding standars fixed

samuel.mortenson’s picture

Status: Needs review » Needs work

Moving to Needs work, the patches so far are unrelated to the original issue. If you would like a configurable copyright block, you can always create a custom block and place it in the footer region (once this issue is Fixed).

dabito’s picture

@samuel.mortenson removing hard-coded copyright from twig is easy, adding a custom block with content via YML has proven a bit of a challenge.

Does anybody have any pointers as to how this could be achieved?

So far, I've tested the following block.block.zurb_foundation_copyright.yml in /config/install with the following contents:

id: zurb_foundation_copyright
plugin: block
langcode: es
status: true
theme: zurb_foundation
region: footer_middle
provider: zurb_foundation
settings:
  id: zurb_foundation_copyright_block
  label: 'Zurb Foundation Copyright'
  label_display: '0'
visibility: {  }

The block gets created and assigned to the correct theme/region, but every other block is cleared upon install and so far I can't figure out how to add block_content only using YMLs...

@tkoleary did you see this working somewhere else we could use as an example?

Thanks!

samuel.mortenson’s picture

You cannot create Content Blocks in .yml files, as they're Content Entities. I'll wait to hear @tkoleary's opinion about the patches so far before proceeding.

tkoleary’s picture

@samuel.mortenson

It is not necessary that it be a "content block." In fact, what it should be is a block generated by a module that provides configuration options, like a text field stored as a string for the copyright holder's name perhaps prefixed with a select box for the user to chose between ©, TM, ®, etc. and a token that uses date to display the current year.

So the form could be:

Field label: Property name
Radios: Site Name, Site URL, Custom (opens text field), None

Field label: Prefix
Select opts: ©, TM, ®

Field label: Date
Radios: Current Year, Custom Date (opens date widget), None

Field label: Intellectual property owner's name
Text field

Field label: Suffix:
Text field

Which could produce any of the following:

  • ©2016, John Smith
  • This Site, ©2016, John Smith
  • www.thissite.com, ©2016, John Smith
  • Mary Jones Logo ®2015, Mary Jones
  • TM, The Business Company, all rights reserved

This would then be something useful in several different contexts as I might want to ® my logo and TM my products as well as © my whole site and get the benefit of having all dates automatically update.

kevinquillen’s picture

I'm all for an interim commit that removes the hard coded values, a change we should strive for.

As for providing a block out of the box for this specific need, I am on the fence about. If it whittles down to just a block, I feel like most people are going to want full control of it anyway, and providing regions seems to be enough to me to grant that ability.

nickbumgarner’s picture

I would probably side with Kevin on this issue. At this point you're just asking to ship editable content out of the box.

samuel.mortenson’s picture

Status: Needs work » Needs review

Putting this back into review, if anyone would like to RTBC the most recent patch I would be willing to commit it to 8.x-6.x. @tkoleary's notes about a module-provided configurable copyright block would have to be addressed in a new project.

hongpong’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.68 KB

I rerolled the patch against 1a6cffb5dc95516a502f7cf28c77d9bef90d1004 by hand, and tested it in Drupal 8.0.6 standard install. it saves the Copyright settings correctly & I believe it is RTBC.

samuel.mortenson’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.52 KB
new3.98 KB

A few nitpicks/changes:

diff -u b/config/install/zurb_foundation.settings.yml b/config/install/zurb_foundation.settings.yml
--- b/config/install/zurb_foundation.settings.yml
+++ b/config/install/zurb_foundation.settings.yml
@@ -24,3 +24,4 @@
   zurb_foundation_page_account_info: true
-  block_copyright_check: true
+  zurb_foundation_block_copyright_custom_text: false
+  zurb_foundation_block_copyright_text: ''

No default value for the custom text, and the naming scheme of the variable doesn't match anything else.

diff -u b/templates/page.html.twig b/templates/page.html.twig
--- b/templates/page.html.twig
+++ b/templates/page.html.twig
@@ -196,19 +196,17 @@
           {% endif %}
         </footer>
       {% endif %}
-      {% if block_copyright %}
...

Checking for block_copyright here hid the normal copyright text unless a custom one was defined, which doesn't make sense. I removed this if statement and kept the normal if/else block.

+  $form['page_elements']['zurb_foundation_block_copyright_custom_text'] = [
     '#type' => 'checkbox',
-    '#title' => t('Use the default Copyright label'),
-    '#default_value' => theme_get_setting('block_copyright_check'),
-    '#tree' => FALSE,
-    '#description' => t('Uncheck here if you want modify the copyright label')
+    '#title' => t('Use custom copyright text'),
+    '#default_value' => theme_get_setting('zurb_foundation_block_copyright_custom_text'),
+    '#description' => t('Check this if you want modify the copyright text.')

Nitpick - I don't like double negatives in forms, and I would like the variable naming/form text here to match what we already have with custom back text.

diff -u b/zurb_foundation.theme b/zurb_foundation.theme
--- b/zurb_foundation.theme
+++ b/zurb_foundation.theme
@@ -337,12 +337,11 @@
   // Variable to disable hard-coded login elements.
   $variables['show_account_info'] = theme_get_setting('zurb_foundation_page_account_info');

-  // Copyright block settings
-  $block_copyright_value = theme_get_setting('block_copyright');
-  $variables['block_copyright'] = $block_copyright_value;
-
-  $block_copyright_check = theme_get_setting('block_copyright_check');
-  $variables['block_copyright_check'] = $block_copyright_check;
+  // Copyright block settings.
+  $variables['block_copyright'] = [
+    '#markup' => theme_get_setting('zurb_foundation_block_copyright_text')
+  ];
+  $variables['block_copyright_custom_text'] = theme_get_setting('zurb_foundation_block_copyright_custom_text');
 }

Rendered the custom copyright text with #markup, which protects against XSS vulnerabilities. As far as I know rendering the raw text in twig would have allowed <script> tags and the like.

hongpong’s picture

Thanks I was wondering about sanitization of the string, not yet familiar with the D8 way. This seems good to me although I don't know if it makes sense to render "bottom-bar panel" even when there is no string going on (in the second chunk of the interdiff). The earlier version had a broader if statement to prevent that rendering. Otherwise RTBC?

samuel.mortenson’s picture

This patch doesn't add an explicit way to remove the copyright - so we would have to do an if statement that checks if a custom copyright is used and that the custom copyright (string) is empty. I would consider conditionally rendering that a distinct setting, so we would need another setting saying something like "Hide copyright block". Someone could add that in this issue if it's needed or open a new issue after this is RTBC'd and committed.

hongpong’s picture

StatusFileSize
new5.31 KB
new4.87 KB

Okay I learned some interesting things in this process. Question: Is it okay to not sanitize the boolean into twig?

I think this has the toggle feature we are looking for, I tested it and it seems to work correctly, with no markup shown if everything is disabled. Please take it for a spin.

samuel.mortenson’s picture

@HongPong Using variables in evaluations like {% if block_copyright_show %} is totally fine, as long as you aren't actually printing them there shouldn't be a risk.

serg2’s picture

Status: Needs review » Needs work

@HongPong

I think we should pick this back up. If you re-roll I can review it.

sim_1’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new60.94 KB
new4.9 KB

I rerolled this by hand so I don't have a interdiff. This should apply to the latest 8.x-6.x dev branch.

I tested it on Drupal 8.7.7 and it appears to work correctly. Marking it as ready for review so someone else can test it as well.

taiger’s picture

Status: Needs review » Reviewed & tested by the community

I tested the copyrightblock-2655760-20.patch in #20 and it works fine.

It does make the copyright go full width now, which is a change, but this seems fine as is. It removes two less unnecessary divs in page.html.twig:

-      <div class="bottom-bar callout secondary">
-        <div class="row">
-          <div class="large-12 columns">
-          &copy; {{ "now"|date('Y') }} {{ site_name }} {{ 'All rights reserved.'|t }}
-          </div>
+      {% if block_copyright_show %}
+        <div class="bottom-bar callout secondary large-12 columns">
+          {% if not block_copyright_custom_text %}
+            <p>&copy; {{ "now"|date('Y') }} {{ site_name }} {{ 'All rights reserved.'|t }}</p>
+          {% else %}
+            {{ block_copyright }}
+          {% endif %}

  • HongPong committed df4914e on 8.x-6.x authored by sim_1
    Issue #2655760 by HongPong, oscarvargas102, samuel.mortenson, sim_1,...
hongpong’s picture

Status: Reviewed & tested by the community » Fixed

Thank you sim_1 and Taiger for revisiting and testing this. I think for now this is a good improvement. Wow that took quite a few years!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.