Skip to content

Instantly share code, notes, and snippets.

View AndreaRivadossi's full-sized avatar
♻️
Keep calm and clear cache

Andrea Rivadossi AndreaRivadossi

♻️
Keep calm and clear cache
View GitHub Profile
@AndreaRivadossi
AndreaRivadossi / readmore.phtml
Last active July 18, 2023 08:36
read more/less, alpine js, for magento 2 hyva themes
<div class="mb-4 leading-relaxed product-description prose"
x-data="{ isCollapsed: false, maxLength: 420, originalContent: '', content: '' }"
x-init="originalContent = $el.firstElementChild.textContent.trim(); content = originalContent.slice(0, maxLength) + '...'">
<p x-text="isCollapsed ? originalContent : content" class="m-0">
<?= /* @noEscape */ $shortDescription ?>
</p>
<a class="inline-flex font-black underline uppercase cursor-pointer text-sm hover:text-orange"
@click="isCollapsed = !isCollapsed"
x-show="originalContent.length > maxLength"
x-text="isCollapsed ? '<?= __('- Read less') ?>' : '<?= __('+ Read more') ?>'">
@AndreaRivadossi
AndreaRivadossi / satis_install.sh
Created August 27, 2018 08:25 — forked from h4cc/satis_install.sh
Guide to install a satis server for composer. It can mirror packages and create a index for own packages.
# Install a Webserver
apt-get -y install apache2
# Target docroot to /home/satis/web/
# Install PHP5 CLI and needed programs.
apt-get -y install php5-cli php5-curl php5-json git wget
# Add a specifix user for our task
adduser satis
@AndreaRivadossi
AndreaRivadossi / robots.txt
Created July 4, 2018 10:31 — forked from hn-support/robots.txt
Magento 2 recommended additions for robots.txt
User-agent: *
# Directories
Disallow: /app/
Disallow: /bin/
Disallow: /dev/
Disallow: /lib/
Disallow: /phpserver/
Disallow: /pkginfo/
Disallow: /report/
@AndreaRivadossi
AndreaRivadossi / Layout-Update-XML.xml
Last active October 12, 2018 13:05
Magento 2 - Add a CSS class to the body element
<referenceContainer name="root" htmlTag="div" htmlClass="my-custom-css-class" htmlId="my-custom-css-id">
</referenceContainer>
@AndreaRivadossi
AndreaRivadossi / alternative_file.phtml
Last active January 7, 2021 14:08
Magento 2 - Add a CMS static block in a .phtml or .xml layout file
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('my-custom-block')->toHtml(); ?>
@AndreaRivadossi
AndreaRivadossi / Debug-Knockout-JS.html
Created May 2, 2018 11:01 — forked from maxcnunes/Debug-Knockout-JS.html
Simple way to debug viewmodel data bind with knockout
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>