add module custom footer
authorValessio Soares de Brito <contato@valessiobrito.com.br>
Thu, 6 Jun 2019 00:18:40 +0000 (20:18 -0400)
committerValessio Soares de Brito <contato@valessiobrito.com.br>
Thu, 6 Jun 2019 00:18:40 +0000 (20:18 -0400)
modules/footer/css/footer.css [new file with mode: 0644]
modules/footer/footer.info.yml [new file with mode: 0644]
modules/footer/footer.libraries.yml [new file with mode: 0644]
modules/footer/footer.module [new file with mode: 0644]
modules/footer/js/footer.js [new file with mode: 0644]
modules/footer/src/Plugin/Block/FooterBlock.php [new file with mode: 0644]
modules/footer/templates/footer.html.twig [new file with mode: 0644]

diff --git a/modules/footer/css/footer.css b/modules/footer/css/footer.css
new file mode 100644 (file)
index 0000000..1de5fb4
--- /dev/null
@@ -0,0 +1,11 @@
+/* Footer */
+
+.footer {
+  color: #FFF;
+  border: none !important;
+}
+.footer a { color: #729fcf; }
+.footer a:hover { color: #FFF; }
+.footer h4 { font-weight: bold; }
+.footer .copyright { font-size: 0.9em; text-align: center; width: 80%; margin-top: 1em; border-top: 1px solid #111; padding: 1em; }
+
diff --git a/modules/footer/footer.info.yml b/modules/footer/footer.info.yml
new file mode 100644 (file)
index 0000000..47d83d4
--- /dev/null
@@ -0,0 +1,8 @@
+name: Footer
+description: Footer
+core: 8.x
+package: RYF Custom Module
+dependencies:
+- node
+- block
+type: module
diff --git a/modules/footer/footer.libraries.yml b/modules/footer/footer.libraries.yml
new file mode 100644 (file)
index 0000000..02b8c58
--- /dev/null
@@ -0,0 +1,7 @@
+footer:
+  css:
+    theme:
+      css/footer.css: {}
+  js:
+    js/footer.js: {}
+
diff --git a/modules/footer/footer.module b/modules/footer/footer.module
new file mode 100644 (file)
index 0000000..7ad9ddb
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/**
+ * @file
+ * Code for the footer module.
+ */
+
+/**
+ * Implements hook_theme()
+ */
+
+function footer_theme($existing, $type, $theme, $path) {
+  return [
+    'footer' => [
+      'variables' => ['menu_array' => NULL ]
+    ],
+
+  ];
+}
diff --git a/modules/footer/js/footer.js b/modules/footer/js/footer.js
new file mode 100644 (file)
index 0000000..1143d61
--- /dev/null
@@ -0,0 +1,5 @@
+(function($){
+       $(document).ready(function(){
+       });
+
+})(jQuery);
diff --git a/modules/footer/src/Plugin/Block/FooterBlock.php b/modules/footer/src/Plugin/Block/FooterBlock.php
new file mode 100644 (file)
index 0000000..485824e
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\footer\Plugin\Block\FooterBlock.
+ */
+namespace Drupal\footer\Plugin\Block;
+use Drupal\Core\Menu\MenuTreeParameters;
+use Drupal\Core\Block\BlockBase;
+use Drupal\node\Entity\Node;
+use Drupal\Core\Block\BlockPluginInterface;
+use Drupal\Core\Form\FormStateInterface;
+
+
+/**
+ * Provides a 'footer' block.
+ *
+ * @Block(
+ *   id = "footer_block",
+ *   admin_label = @Translation("Footer"),
+ *   category = @Translation("RYF Custom Module")
+ * )
+ */
+class FooterBlock extends BlockBase implements BlockPluginInterface {
+  /**
+   * {@inheritdoc}
+   */ 
+    public function build() {
+
+      $menu_tree_parameters = new MenuTreeParameters();
+      $tree = \Drupal::menuTree()->load('footer', $menu_tree_parameters); 
+
+      $cc = 0;
+      foreach($tree as $menu){ 
+        $title     = $menu->link->getTitle();
+        $urlObject = $menu->link->getUrlObject();
+        $url       = $urlObject->toString();
+        $weight    = $menu->link->getWeight();
+        $enabled   = $menu->link->isEnabled();
+
+        if($enabled) {
+          $menu_array[$cc]['title']    = $title;
+          $menu_array[$cc]['url']      = $url;
+          $menu_array[$cc]['weight']   = $weight;
+          $cc++;
+        }
+
+      }
+
+      usort($menu_array, function($a, $b) {
+          return $a['weight'] - $b['weight'];
+      });
+
+           return array(
+        '#theme' => 'footer',
+        '#menu_array' => $menu_array,
+                       '#attached' => array(
+                       'library' => array(
+                               'footer/footer',
+                       ),
+               ),
+
+           );
+
+       }
+
+}
diff --git a/modules/footer/templates/footer.html.twig b/modules/footer/templates/footer.html.twig
new file mode 100644 (file)
index 0000000..8425117
--- /dev/null
@@ -0,0 +1,47 @@
+<div class="container">
+<div class="col-md-4">
+<div class="ryf-footer">
+<p><img alt="Free Software Foundation" src="/themes/ryf/images/fsf-logo.svg" /></p>
+
+<p>Send your feedback on our translations and new translations of pages to <a href="#">campaigns@fsf.org</a>.</p>
+</div>
+</div>
+
+<div class="col-md-offset-2 col-md-3">
+<div class="campaigns">
+<h4>Campaigns</h4>
+
+<ul>
+        <li><a href="/campaigns/priority-projects/">High Priority Free Software Projects</a></li>
+        <li><a href="/campaigns/freejs/">Free JavaScript</a></li>
+        <li><a href="/campaigns/campaigns/secure-boot-vs-restricted-boot/">Secure Boot vs Restricted Boot</a></li>
+        <li><a href="/windows/">Upgrade from Windows</a></li>
+        <li><a href="/campaigns/surveillance/">Surveillance</a></li>
+        <li><a href="https://www.gnu.org/">GNU Operating System</a></li>
+        <li><a href="https://defectivebydesign.org/">Defective by Design</a></li>
+        <li><i><a href="##">See all campaigns</a></i></li>
+      </ul>
+
+</div>
+<!-- .campaigns --></div>
+
+<div class="col-md-3">
+<div class="get-involved">
+<h4>Get Involved</h4>
+
+<ul>
+                {% for this_menu in menu_array %}
+                    <li>
+                        <a class="footer-link" href="{{ this_menu.url }}">{{ this_menu.title }}</a>
+                    </li>
+                {% endfor %}
+</ul>
+</div>
+<!-- .get-involved --></div>
+</div>
+
+<div class="container copyright">Send your feedback on our translations and new translations of pages to <a href="mailto:campaigns@fsf.org">campaigns@fsf.org</a>.
+ <br />Copyright © 2004–{{ "now"|date("Y") }} <a href="//fsf.org/about/contact.html" title="Find out how to contact us">Free Software Foundation</a>, Inc.
+ <a href="https://my.fsf.org/donate/privacypolicy.html">Privacy Policy</a>.
+</div>
+