shahroq / whale_c5_cheat_sheet Goto Github PK
View Code? Open in Web Editor NEWconcrete5 Cheat Sheet
License: MIT License
concrete5 Cheat Sheet
License: MIT License
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!
Could anyone complete updating the general checkboxes section here?
(I marked it with "help wanted")
https://github.com/shahroq/whale_c5_cheat_sheet#create-the-entity
@mlocati
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.
public function getSearchableContent()
{
return $this->title . ' ' . $this->paragraph;
}
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;
}
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
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
Starting with concrete5 8.5.2, there is a new global app()
helper function.
concretecms/concretecms#8011
I am not entirely sure what the cheat sheet text should be. I imagine @mlocati might have an opinion on it.
$editor = $app->make('editor');
echo $editor->outputStandardEditor('content', $content);
$editor = $app->make('editor');
$pluginManager = $editor->getPluginManager();
$plugins = $pluginManager->getAvailablePlugins();
foreach ($plugins as $p) {
echo $p->getKey().' - '.$p->getName().'<br>';
}
$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);
How about adding a section for v9 specific stuff? Only for what's different from v8 or new, e.g. Tasks etc..
For example:
https://forums.concretecms.org/t/v9-group-add-and-delete-deprecated-what-to-use-instead/1499
https://forums.concretecms.org/t/v8-to-v9-package-conversion-tabs/1414
https://forums.concretecms.org/t/v8-to-v9-package-conversion-how-to-get-user-ip-address/1406/2
https://forums.concretecms.org/t/v9-how-to-make-tooltips-work-in-block-edit-form/1389
I guess $page->isSystemPage()
was meant to show if the page is a Dashboard page, and if so, it's not actually what it is, it should be $page->isAdminArea()
.
https://documentation.concrete5.org/api/8.5.2/Concrete/Core/Page/Page.html#method_isSystemPage
vs
https://documentation.concrete5.org/api/8.5.2/Concrete/Core/Page/Page.html#method_isAdminArea
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.');
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...
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.
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);
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');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.