Skip to content

Instantly share code, notes, and snippets.

@litzinger
litzinger / ee-tips.md
Last active August 24, 2023 18:17
ExpressionEngine Quick Tips

Forcing a database update

If you're in a situation where you've already updated EE, but then need to run the database upgrades again, this will help force the installer to run the updates again. This situation may occur if you've upgrade a local or dev version of a site, but need to grab a newer version of the production database to get it up-to-date too.

  1. Change $config['app_version'] to the previous version you've already upgraded from.

  2. Add define('INSTALL_MODE', TRUE); to your admin.php file, then reload admin.php. Clicking the version number in the footer should show an update is available, even though it may match what says is currently installed. Run the update normally, then remove define('INSTALL_MODE', TRUE); from your admin.php file.

OR

@litzinger
litzinger / grid.css
Created September 19, 2018 14:10
Simple CSS Grid layout without a framework
.container {
padding: 0 1rem;
margin: 0 auto;
}
@media screen and (min-width: 992px) {
.container {
max-width: 1140px;
}
.grid-wrapper {
display: grid;
@litzinger
litzinger / gist:7719412e728bb0f7579b6dcaad1d3d91
Created August 17, 2018 14:50
Visual Studio Code XDebug config
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// Set the IDEKEY in the browser Xdebug Helper extension to "vscode"
"version": "0.2.0",
"configurations": [
{
@litzinger
litzinger / hook.php
Created October 31, 2017 17:37
Publisher hook example
<?php
$query = $this->query->modify(
'ORDER BY',
' AND ae.publisher_lang_id = '. $publisher_lang_id .' AND ae.publisher_status = "'. $publisher_status .'" ORDER BY',
$sql
);
// Publisher is disabled, but we still need to get default rows,
// otherwise it'll show duplicate rows.
@litzinger
litzinger / relationship-entry_ids.diff
Created July 24, 2017 20:44
{relationship_field:entry_ids} is not available in EE2, but is in EE3. Take the code from EE3 and put it into EE2.
.../expressionengine/libraries/relationship_parser/Parser.php | 10 ++++++++++
.../libraries/relationship_parser/Tree_builder.php | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git system/expressionengine/libraries/relationship_parser/Parser.php system/expressionengine/libraries/relationship_parser/Parser.php
index 6a7d61d21..3cb6bdeed 100644
--- system/expressionengine/libraries/relationship_parser/Parser.php
+++ system/expressionengine/libraries/relationship_parser/Parser.php
@@ -188,6 +188,16 @@ class EE_Relationship_data_parser {
<?php
/**
* @var mixed $data
* This is the incoming parameter value. If multiple add-ons use the same hook the same $data value
* is given to each hook call, regardless of what order the hooks are called in.
*/
public function some_extension_hook($data)
{
// If last_call contains a value, then it means another extension used this same hook before yours,
@litzinger
litzinger / acceptance.php
Created March 10, 2017 16:15
fillField method that works in Safari
<?php
// https://codete.com/blog/automating-acceptance-testing/
/**
* Fills a text field or textarea with the given string.
*
* @param string $field field
* @param string $value value
*
<?php
if (isset($_GET['publisher_status'])) {
$assign_to_config['global_vars']['global:tag_cache'] = '';
} else {
$assign_to_config['global_vars']['global:tag_cache'] = 'cache="yes" refresh="14440"';
}
<?php
class ImageRenderer
{
const BREAK_POINTS = '1199|991|768|500|320';
const MOBILE_BREAKPOINT = 2; // which index of BREAK_POINTS is deemed "mobile"?
const PERCENTAGES = '1|0.8|0.6|0.4|0.3';
const QUALITY = 75;
const DIRECTORY = '/_images/remote/';
const RETINA_IDENTIFIER = '@2x';
"It would be nice if, similar to Laravel's blade templating, a master template could be defined and
have placeholder sections where other templates or code can be inserted."
- https://docs.expressionengine.com/latest/templates/layouts.html
"It's unfortunate there isn't a tool similar to composer/packagist that can be used to easily find
and install open source third-party add-ons as easily as Laravel allows. Composer could probably be
used to manage dependencies, but it's not something built in, and the number of packages for EE on
packages is probably fairly low."