I've search for several hours how to hide a specific content type.
I found some post but they are too older and their solutions doesn't work in the actual's strapi.
For precisions, my collection type is declared inside a local plugin. I juste want to manage my collection inside the plugin page and I doesn't want it appear in the content type in the left menu.
If someone has a solution, it's can be really helpfull.
In new version of Strapi v3.6.6 — Community Edition there is an option in model
{
"kind": "collectionType",
"collectionName": "test",
"info": {
"name": "test"
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
**"pluginOptions": {
"content-manager": {
"visible": false
}
},**
"attributes": {
"name": {
"type": "string",
"required": true
},
}
}
They are working on this: https://github.com/strapi/rfcs/pull/22
But for now, based on official docs (plugin customization), you can overwrite file in content-manager plugin.
Be sure to check this file on strapi updates to avoid overwriting important code.
Copy file strapi-plugin-content-manager/services/data-mapper.js from your app node_modules into extensions/content-manager/services/
Now edit this file in your project and add your content type to array HIDDEN_CONTENT_TYPES following this pattern: plugins::[plugin-name].[content-type]
For example: plugins::ecommerce.product
...
const HIDDEN_CONTENT_TYPES = [
'plugins::upload.file',
'plugins::users-permissions.permission',
'plugins::users-permissions.role',
'plugins::ecommerce.product',
];
...
You can extend the plugin to make updates to the content-type's schema.
Copy the content-type schema from the plugin to your src folder.
In my case, I copied /strapi-plugin-navigation/server/content-types/audience/schema.json to /src/extensions/navigation/content-types/audience/schema.json (notice that the strapi-plugin- part of the folder name is removed) and added the following to it to hide the "Audience" content type from the content manager and content-type builder:
"pluginOptions": {
"content-manager": {
"visible": false
},
"content-type-builder": {
"visible": false
}
},
Official documentation here.
In Strapi v4 it is "visible": false
{
"kind": "collectionType",
"collectionName": "bookmark",
"info": {
"singularName": "bookmark",
"pluralName": "bookmarks",
"displayName": "Bookmark",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"index": {
"type": "integer",
"unique": false,
"visible": false
},
}
}
I'm trying to upgrade Twig 1.13.2-DEV to 3.x but don't know how to do that as on their
Website not clearly mentioned and they suggest to ask question on StackOverflow :)
I used Twig only with Symfony framework not with Custom PHP website, Right now I can see two directories in server
Twig
Twig-extensions
And inside /Twig/lib/Twig/Environment.php it display me the version
const VERSION = '1.13.2-DEV';
Can someone have idea how to upgrade Twig?
My project is not using composer.json but inside Twig folder I have this compsoer.json
"name": "twig/twig",
"type": "library",
"description": "Twig, the flexible, fast, and secure template language for PHP",
"keywords": ["templating"],
"homepage": "http://twig.sensiolabs.org",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien#symfony.com"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher#active-4.com"
}
],
"require": {
"php": ">=5.2.4"
},
"autoload": {
"psr-0" : {
"Twig_" : "lib/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
}
}
I'm trying to setup my app descriptor file (manifest.json) to include a named model, 'inputs' in its "models" object. From my understanding, after doing so, the model should be available throughout the app when provided the correct path (see XML View).
The reason I'd like to setup this manifest.json is because it's a best practice to configure all models in here.
In the controller, I'd like to get and then set the 'inputs' Model defined in the manifest.json --but how can this be done?
manifest.json (Where I have configured the 'inputs' model)
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "pricingTool",
"type": "application",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"ach": "ach",
"resources": "resources.json",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.30.3"
},
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone#2": "",
"tablet": "",
"tablet#2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_bluecrystal"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "pricingTool.view.Main",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"inputs": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/inputs.json"
},
},
}
Main.controller.js (where the 'inputs' model should be set from the manifest file)
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel',
'sap/ui/model/Filter',
'sap/ui/model/FilterOperator',
'sap/m/MessageToast',
'pricingTool/model/viewControls',
'pricingTool/model/formatter',
'pricingTool/model/Utility',
'sap/ui/core/util/Export',
'sap/ui/core/util/ExportTypeCSV',
],
function (jQuery, Controller, JSONModel, Filter, FilterOperator, MessageToast, viewControls, formatter, Utility, Export, ExportTypeCSV) {
"use strict";
var mainController = Controller.extend("pricingTool.controller.Main", {
onInit: function(oEvent) {
//define named/default model(s)
var inputs = new JSONModel("./model/inputs.json");
//set model(s) to current xml view
this.getView().setModel(inputs, "inputs");
//this is one solution I have tried, but doesn't do anything:
// this.getView().setModel(this.getOwnerComponent().getModel("inputs"), "inputs");
//another solution I have tried:
//var inputs = this.getModel('input') <--I was hoping this would find the inputs defined in the manifest.json, but this doesn't work either
// this.getView().setModel(inputs, "inputs");
},
...
inputs.json
{
"propA" : "testVal"
}
XML View
<Button text="{inputs>propA}"></Button>
Components.js (Not sure what to do in the Component.js)
sap.ui.define([
'sap/ui/core/UIComponent'
],
function(UIComponent) {
"use strict";
var Component = UIComponent.extend("pricingTool.Component", {
metadata : {
metadata : {
manifest: "json"
},
rootView : "pricingTool.view.Main",
dependencies : {
libs : [
"sap.m",
"sap.ui.layout"
]
},
config : {
sample : {
files : [
"Main.view.xml",
"Main.controller.js"
]
}
}
},
init : function () {
// call the init function of the parent
UIComponent.prototype.init.apply(this, arguments);
}
});
return Component;
});
The problem is that the model property ("propA") is not displaying when I test it on a button control. Can anyone tell me why the model is not displaying in the app?
Summarizing Question
How can I define a model in manifest.json, and then set that model in the controller so I can use it in my xml view?
try putting a forward slash before your property name...
<Button text="{inputs>/propA}"></Button>
...and update your manifest file so that your model definition points to your dataSource defined under sap.app as follows...
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "pricingTool",
"type": "application",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"ach": "ach",
"resources": "resources.json",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.30.3"
},
"dataSources": {
"inputsData": {
"type" : "JSON",
"uri": "model/inputs.json"
}
}
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone#2": "",
"tablet": "",
"tablet#2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_bluecrystal"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "pricingTool.view.Main",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"products": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/products.json"
},
"inputs": {
"type": "sap.ui.model.json.JSONModel",
"dataSource" : "inputsData"
}
}
}
}
...change your Component.js file to point to your manifest file...
sap.ui.define([
'sap/ui/core/UIComponent'
],
function(UIComponent) {
"use strict";
var Component = UIComponent.extend("pricingTool.Component", {
metadata : {
manifest: "json",
},
init : function () {
// call the init function of the parent
UIComponent.prototype.init.apply(this, arguments);
}
});
});
... and remove the onInit logic within your controller to set the model (this is handled by the component)
Those models you define in the manifest.json file are created in the Component context (if your app based on Component). To make it available in the XML view you have to obtain it from Component and then attach to the view. The code snippet you can use in onInit controller event looks like this:
this.getView().setModel(this.getOwnerComponent().getModel("<your_model_name>"), "<your_model_name>");
if you are using standard template then most likely you have a BaseController as an ancestor, in that case the code can look shorter:
this.setModel(this.getComponentModel("<your_model_name>"), "<your_model_name>");
Here is a minimal example of what you'd like to achieve: https://embed.plnkr.co/l1XF5O/
Models defined in manifest.json (aka. "app descriptor") will be set to the component (since v1.30).
If a descriptor is used, almost all properties of your component's metadata other than manifest: "json" are deprecated and should be avoided. Deprecated properties are listed here.
Views (and their controls inside) inside the root view instantiated by your component inherit models automatically from the component. Thus, setting models to your view explicitly is not needed anymore. Your view already knows the model that is set to the component.*
The binding syntax should be used correctly according to your situation:
Use relative binding syntax (modelName>property) only if a parent control has already a context bound (e.g. the parent control uses aggregation binding, or element binding).
In other cases, use absolute binding syntax. It starts with a slash (modelName>/property), so that the control doesn't look for the binding context of its parent.
*Although the model, which is set on the component, can be used seamlessly in the XMLView, retrieving the component model by calling view.getModel inside the onInit handler will return undefined. More about this: https://stackoverflow.com/a/43941380/5846045
I'm using a grunt plugin called bower-concat. This plugin takes all your bower_component packages and concatenates them into a single file. It does this by looking at each component's bower.json file's "main" attribute. I'd like to modify my font-awesome's bower.json "main" attribute from
{
"name": "font-awesome",
"description": "Font Awesome",
...,
"main": [
"less/font-awesome.less",
"scss/font-awesome.scss"
]
...
}
to this, which allows my grunt-bower-concat plugin to work.
{
"name": "font-awesome",
"description": "Font Awesome",
...,
"main": [
"./css/font-awesome.css",
"./fonts/*"
]
...
}
By following this post here (https://roots.io/using-bootstrap-with-bower-how-to-override-bower-packages/), I thought I'd be able to override this attribute like so in my app's bower.json file to achieve the desired result upon bower install ...
{
"name": "MyApp"
"dependencies": {
"font-awesome": "~4.4.0"
},
"overrides": {
"font-awesome": {
"main": [
"./css/font-awesome.css",
"./fonts/*"
]
}
}
}
Unfortunately, this doesn't appear to override font-awesome's "main" attribute. Can anyone point out what I'm missing?
I am trying to use a Bundle inside a Bundle but somehow it is failig.
"repositories": [
{
"type": "vcs",
"url": "https://github.com/myname/mybundle"
}
],
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
(...)
"myname/mybundle": "*"
},
this seems to work so far. But I can't figure out how to declare another dependency within "myname/mybundle".
I tried the following in the composer.json file of myname/mybundle but none of them worked :(
"repositories": [
{
"type": "vcs",
"url": "url": "https://github.com/drymek/PheanstalkBundle"
}
],
"require": {
(...)
"drymek/PheanstalkBundle": "dev-master"
}
and
"repositories": [
{
"type": "package",
"package": {
"name": "drymek/PheanstalkBundle",
"version": "dev-master",
"source": {
"url": "https://github.com/drymek/PheanstalkBundle.git",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
(...)
"drymek/PheanstalkBundle": "dev-master"
}
when I rum composer.phar update all i get is
- myname/mybundle dev-master requires drymek/pheanstalkbundle dev-master -> no matching package found.
Okay I've found an answer here
It states: Repositories are not resolved recursively. You can only add them to your main composer.json. Repository declarations of dependencies' composer.jsons are ignored.
That's too bad... but now at least I know where to put my dependeny (in the root composer.json file)
For bundle dependencies, please see my library https://github.com/AshleyDawson/MultiBundle. As an example, extend the MultiBundle and implement the getBundles() method, like so:
<?php
namespace Acme\MyBundle;
use AshleyDawson\MultiBundle\AbstractMultiBundle;
class AcmeMyBundle extends AbstractMultiBundle
{
/**
* Optional: define a protected constructor to stop instantiation outside of registerInto()
*/
protected function __construct()
{
}
/**
* Define bundles that this bundle depends on
*/
protected static function getBundles()
{
return array(
new Acme\FooBundle\AcmeFooBundle(),
new Acme\BarBundle\AcmeBarBundle(),
);
}
}
And then in the AppKernel register the bundle and it's dependencies:
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
// ...,
);
// Register my bundle and its dependencies
\Acme\MyBundle\AcmeMyBundle::registerInto($bundles);
// ...
}
}