Giter VIP home page Giter VIP logo

whale_c5_cheat_sheet's People

Contributors

apaccou avatar biplobice avatar dimger avatar jocomail78 avatar mesuva avatar mlocati avatar mnakalay avatar shahroq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whale_c5_cheat_sheet's Issues

[Documentation] Improvement - Express Entry - order

Hey so again, I don't have PR permissions or whatever, but just wanted to post something helpful.

In the section:

// select
$eObj->addAttribute('select', 'Facilities', 'marina_facilities', $settings);
$settings = new \Concrete\Core\Entity\Attribute\Key\Settings\SelectSettings();
$settings->setAllowMultipleValues(false);
$settings->setDisplayMultipleValuesOnSelect(false);
$settings->setHideNoneOption(false);
$settings->setAllowOtherValues(false);
$settings->setDisplayOrder('display_asc');

It seems to me that the "$eObj" line should be at the end, otherwise it will fail since the $settings variable will neither exist, nor have the desired parameters set for it. AFAIK order of operations matter in this regard.

Hope this helps!

use getUserGroupObjects() instead of getUserGroups()

Hello,

When getting the groups a user belongs to, you're getting an array of group IDs using getUserGroups() then looping to get all the group objects by ID. You could get them directly by using getUserGroupObjects() instead of getUserGroups()

That function uses a GroupList object and filters it by the User ID so it might be marginally more efficient.

Enable block content indexing and searching

  1. Simple block title and content:
public function getSearchableContent()
{
    return $this->title . ' ' . $this->paragraph;
}
  1. Block with custom entity's object:
public function getSearchableContent()
{
    $content = '';
    $page = $this->getCollectionObject();
    if (!$page->isError()) {
        $cid = $page->getCollectionID();
        if ($cid) {
            $my_object = MyObject::getByCollectionID($cid);
            if ($my_object) {
                $content = $my_object->getTitle() . ' ' . trim(strip_tags(html_entity_decode($my_object->getContent(), ENT_QUOTES, 'UTF-8')));
            }
        }
    }
    return $content;
}

Superglobals section

In the superglobal section, the get() function also takes a second parameter to serve as a fallback value if the key is not present. So

$request->request->get('key', 'some default value')

will return 'some default value' if $_POST['key'] doesn't exist

There are lots of other useful functions available like

  • all() to get the whole array
  • keys() to get an array of all the keys
  • has() to check if a key exists

And many others

It's probably not a good idea to list them all but you could reference the file where those functions are available for people to check. It's vendor\symfony\http-foundation\ParameterBag.php

Rich Text Editor

  1. Simple RTE use:
$editor = $app->make('editor');
echo $editor->outputStandardEditor('content', $content);
  1. List RTE plugins:
$editor = $app->make('editor');
$pluginManager = $editor->getPluginManager();
$plugins = $pluginManager->getAvailablePlugins();
foreach ($plugins as $p) {
    echo $p->getKey().' - '.$p->getName().'<br>';
}
  1. Strip all RTE plugins and enable some as required:
$editor = $app->make('editor');
$pluginManager = $editor->getPluginManager();
$selectedPlugins = $pluginManager->getSelectedPlugins();
$allowedPlugins = ['wysiwygarea', 'image', 'image2', 'undo', 'toolbar', 'clipboard', 'format', 'basicstyles', 'justify'];
$pluginManager->deselect($selectedPlugins);
$pluginManager->select($allowedPlugins);
echo $editor->outputStandardEditor('content', $content);

Replace home page with another page

@mlocati @mnakalay
Do you think it would be possible to come up with a piece of code that swap a page with the root page using c5 API?
It should swap all entities linked to a page, including blocks, stacks, areas, attributes, page template/type, versions, etc.

[suggestion] How about adding a section for v9 specific stuff?

Logging to a new channel

Logging to a new channel. This works for any of the levels - e.g. addNotice, addAlert, etc.

use Concrete\Core\Logging\LoggerFactory;

$logger = $this->app->make(LoggerFactory::class)->createLogger('your_new_channel');
$logger->addNotice('A notice level log message.');
$logger->addInfo('A info level log message.');

Moving this repository to concrete5-community?

This repository is so useful that it deserves more visibility.

So, what about moving it under the https://github.com/concrete5-community umbrella?

So, I don't see any issue...

Japanese branch

Thank you for great cheat sheet.
I started to translate Japanese version.

Would you add Japanese branch?
I want to send PR to Japanese branch, not master.

Item Lists and Pagination

Could you please add these to the pagination for v8.4+:

FolderItemList:

use Concrete\Core\Tree\Node\Type\FileFolder;
use Concrete\Core\File\FolderItemList;
use Concrete\Core\Search\Pagination\PaginationFactory;
use Concrete\Core\Http\Request;

$file_folder = FileFolder::getByID($this->file_folder);
if ($file_folder) { 
    $files = new FolderItemList();
    $files->filterByParentFolder($file_folder);
    $files->setItemsPerPage($this->num_files);
    $files->sortByNodeName();
    
    $factory = new PaginationFactory($this->app->make(Request::class));
    $paginator = $factory->createPaginationObject($files);
    $pagination = $paginator->renderDefaultView();
    $this->set('files', $paginator->getCurrentPageResults());
    $this->set('pagination', $pagination);
    $this->set('paginator', $paginator);
}

FileList:

use Concrete\Core\File\FileList;
use Concrete\Core\Search\Pagination\PaginationFactory;
use Concrete\Core\Http\Request;

$files = new FileList();
$files->setItemsPerPage($this->num_files);
$files->sortByFilenameAscending();

$factory = new PaginationFactory($this->app->make(Request::class));
$paginator = $factory->createPaginationObject($files);
$pagination = $paginator->renderDefaultView();
$this->set('files', $paginator->getCurrentPageResults());
$this->set('pagination', $pagination);
$this->set('paginator', $paginator);

Legacy ItemList:

use Concrete\Core\Legacy\ItemList;
use Concrete\Core\Search\Pagination\PaginationFactory;
use Concrete\Core\Http\Request;

$files = new ItemList();
$files->setItemsPerPage($this->num_files);
$files->setItems($contents);

$factory = new PaginationFactory($this->app->make(Request::class));
$paginator = $factory->createPaginationObject($files);
$pagination = $files->displayPagingV2(false, true);
$this->set('files', $files->getPage());
$this->set('pagination', $pagination);
$this->set('paginator', $paginator);

[Documentation] Express Entity - Create the entity - User Selector

Hey so I don't have permissions to PR or whatever, so I'm just going to paste here something I found worth adding to the documentation as it is absent, but testing shows this works:

// user_selector
$eObj->addAttribute('user_selector', 'Which User', 'which_user');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.