This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private const string HOME_SLUG = '__home__'; | |
| Event::on(Entry::class, Entry::EVENT_BEFORE_SAVE, function (Event $event) { | |
| $element = $event->sender; | |
| if ($element->section->handle !== 'pages') { | |
| return; | |
| } | |
| if ($element->parentId === null && $element->slug !== self::HOME_SLUG) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // If you need all your slides to have same height, | |
| // add the CSS selector to your slider cells and use this code in your CSS: | |
| // CSS | |
| .carousel-cell { | |
| display: flex; | |
| align-items: stretch; | |
| min-height: 100%; | |
| } | |
| .carousel .flickity-slider { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "label": "Afghanistan", | |
| "value": "af", | |
| "default": false | |
| }, | |
| { | |
| "label": "Åland Islands", | |
| "value": "ax", | |
| "default": false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const countries = { | |
| AF: {name: "Afghanistan",phone: 93,symbol: "؋",currency: "AFN",continent: "Asia",continent_code: "AS",alpha_3: "AFG"}, | |
| AX: {name: "Aland Islands",phone: 358,symbol: "€",currency: "EUR",continent: "Europe",continent_code: "EU",alpha_3: "ALA"}, | |
| AL: {name: "Albania",phone: 355,symbol: "Lek",currency: "ALL",continent: "Europe",continent_code: "EU",alpha_3: "ALB"}, | |
| DZ: {name: "Algeria",phone: 213,symbol: "دج",currency: "DZD",continent: "Africa",continent_code: "AF",alpha_3: "DZA"}, | |
| AS: {name: "American Samoa",phone: 1684,symbol: "$",currency: "USD",continent: "Oceania",continent_code: "OC",alpha_3: "ASM"}, | |
| AD: {name: "Andorra",phone: 376,symbol: "€",currency: "EUR",continent: "Europe",continent_code: "EU",alpha_3: "AND"}, | |
| AO: {name: "Angola",phone: 244,symbol: "Kz",currency: "AOA",continent: "Africa",continent_code: "AF",alpha_3: "AGO"}, | |
| AI: {name: "Anguilla",phone: 1264,symbol: "$",currency: "XCD",continent: "North America",continent_code: "NA",alpha_3: "AIA"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{ | |
| "name": "Afghanistan", | |
| "dial_code": "+93", | |
| "emoji": "🇦🇫", | |
| "code": "AF" | |
| }, | |
| { | |
| "name": "Aland Islands", | |
| "dial_code": "+358", | |
| "emoji": "🇦🇽", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $str = 'A string with <br> tags. Lorem ipsum dolor <br/> Nullam id elementum nisl <br />at sagittis lorem.' | |
| // Replace <br> <br/> and <br /> with a blank space | |
| $str = preg_replace('#<br\s*/?>#i', ' ', $str); | |
| echo $str; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% for item in items %} | |
| {% if loop.index0 is divisible by(2) %} | |
| {% endif %} | |
| {% endfor %} | |
| {# | |
| 1st - returns false | |
| 2nd - returns true | |
| 3rd - returns false | |
| 4th - returns true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let scrollpos = window.scrollY; | |
| // Document ready | |
| document.addEventListener("DOMContentLoaded", () => { | |
| // Window scroll | |
| window.addEventListener('scroll', () => { | |
| scrollpos = window.scrollY; | |
| console.log(scrollpos); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set entry = craft.entries({ | |
| section: 'blog', | |
| where: ['sounds like', 'title', 'too'] | |
| }).one() %} | |
| {# returns: two #} | |
| {% set entry = craft.entries({ | |
| section: 'blog', | |
| where: ['like', 'title', 'rob'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set entries = craft.entries({ | |
| section: 'schoolsAndColleges', | |
| orderBy: ("(CASE WHEN `title` LIKE 'The %' THEN SUBSTRING(`title`, 5) WHEN `title` LIKE 'A %' THEN SUBSTRING(`title`, 3) ELSE `title` END) asc"), | |
| limit: 10, | |
| }) %} |
NewerOlder