Skip to content

Instantly share code, notes, and snippets.

return [
'fa-500px' => 'fa-500px',
'fa-address-book' => 'fa-address-book',
'fa-address-book-o' => 'fa-address-book-o',
'fa-address-card' => 'fa-address-card',
'fa-address-card-o' => 'fa-address-card-o',
'fa-adjust' => 'fa-adjust',
'fa-adn' => 'fa-adn',
'fa-align-center' => 'fa-align-center',
'fa-align-justify' => 'fa-align-justify',
@iboved
iboved / cache.html
Created November 25, 2020 15:35
Cache partial
public function onRender()
{
$content = \Cache::rememberForever('menu-data-'.$this->alias, function() {
return $this->renderPartial('::default.htm', ['menuItems' => $this->menuItems()]);
});
return $content;
}
@iboved
iboved / default.htm
Created September 29, 2020 07:21
Menu structure
{% if __SELF__.menuItems %}
<ul>
{% for item in __SELF__.menuItems if not item.viewBag.isHidden and item.viewBag.published_locales[activeLocale] %}
<li {{ item.isActive or item.isChildActive ? 'class="active"' }}>
{% if item.url %}
<a href="{{ item.url ?: '#' }}" {{ item.viewBag.isExternal ? 'target="_blank"' }}>
{{ item.viewBag.menu_title }}
</a>
{% else %}
{{ item.viewBag.menu_title }}
<fieldset class="mb-3" data-name="form-agreement">
<div class="form-row">
<div class="col">
<div class="br_hotels-filter-hidden__checkbox">
<input type="checkbox" name="data_protection" id="data-protection" class="is-invalid">
<span>Yes, I have taken note of the data protection statement and give the consent to the collection and use of my data entered above *</span>
<div class="invalid-feedback">The Data protection statement must be accepted.</div>
</div>
<div class="br_hotels-filter-hidden__checkbox">
<input type="checkbox" name="terms" id="terms" class="is-invalid">
<fieldset class="mb-3" data-name="form-agreement">
<div class="form-row">
<div class="col">
<div class="form-check">
<input class="form-check-input is-invalid" type="checkbox" name="data_protection" id="data-protection">
<label class="form-check-label" for="data-protection">
Yes, I have taken note of the data protection statement and give the consent to the collection and use of my data entered above *
</label>
<div class="invalid-feedback">The Data protection statement must be accepted.</div>
</div>
@iboved
iboved / help.md
Last active July 10, 2020 12:43
Laravel | Limit the number of characters in a string and leave the full word at the end.

Description:

Limit the number of characters in a string and leave the full word at the end using the Laravel Framework. In other words, do not cut the word at the end of the line. Assume the only requirement is "limit+ character string that is composed of full words".

Algorithm:

  1. Call Str::limit($limit) and save the result.
  2. Count words in that result.
  3. Call Str::words() to get that number of words from the original string.

Example:

<?php
private function redirectToCmsPage(RedirectRule $rule): string
{
$parameters = [];
// Strip curly braces from keys
foreach ($rule->getPlaceholderMatches() as $placeholder => $value) {
$parameters[str_replace(['{', '}'], '', (string) $placeholder)] = $value;
}
<!-- Accommodation 1 -->
<div class="row rooms">
<div class="col-12">
<h6>
Room 1
</h6>
<div class="form-group row">
<label>Adults</label>
<input type="number" name="accommodations[1][adults]" value="2" min="1" max="5">
<span>ex 18 years</span>
@iboved
iboved / upgrade.md
Last active November 7, 2019 08:53
Upgrade steps

Upgrade steps:

  1. Update the composer.json file in ALL installations. Here is the correct composer.json file. New commands/dependencies have been added to this file (for example, the Package Discovery command). Now Aliases and Service Providers are registered automatically in OctoberCMS if the package uses Package Discovery.

  2. Upgrade OctoberCMS to 458 Build. If you use composer for upgrading (composer update command), make sure you have 'edgeUpdates' => false and 'disableCoreUpdates' => true in your /config/cms.php file. I remember we had some problems with js/css stuff when upgrading OctoberCMS via composer. We used some commands from this list to compile OctoberCMS backend assets. As for me, I didn't have any problems with backend assets and I didn't run these commands. Perhaps because I installed a new OctoberCMS project with the latest 458 Buil

{
"name": "october/october",
"description": "OctoberCMS",
"homepage": "https://octobercms.com",
"type": "project",
"keywords": ["october", "cms", "octobercms", "laravel"],
"license": "MIT",
"authors": [
{
"name": "Alexey Bobkov",