Add extra field on "File Upload" widget of OctoberCMS - php

I want to add an extra field to the Upload Files widget,
how I can do that?
What I actually have:
I changed DB (hardcoded on phpMyAdmin)
This is an updated _config_form.htm
And I have added this to FileUpload.php
Error on saving:

The problem was on the name of the new field...
So If change "data" to for example "params" all will work great:

You should not edit any core files directly, better way would be to create plugin, inside plugin create formwidget that extends from FileUpload.php give your widget an alias and use that alias instead of fileupload.
To add another field before $file->save() just override onSaveAttachmentConfig() method and that's it.
Problem with FileUpload is that it reads config from partial and not from config so it's hard to extend view that's pesented to users.
At least it was case with me, a had to add tags, taglist field and image crop inside multi image upload widget.
It was really complicated.

Related

Yii2: add field to autogenerated CRUD (automatically?)

Yii2 has a feature of generating CRUD for table with gii.
It creates several files: controller, model, search model and views.
What if after generating CRUD I need to add more fields to the table? I see that I need to change:
Model's
phpdoc
rules()
attributeLabels()
Search model's
rules()
search() (tweak ->andFilterWhere() calls)
Views:
index (grid columns)
_form (model inputs)
_search (search inputs)
view (attribute rows)
A lot of work. Is there a way to do it easier/automatically? I understand that I can just regenerate CRUD with gii, but in this case all my other tweaks would be overwritten (lost).
Maybe there exist some other CRUD solution for Yii2, that does not hardcode all fields and allows table schema changes to appear automatically in the views/models? Would be glad to know about it.
If you dont want to overwrite file or add changes manually , you have below option:
In Gii, after clicking preview button you can see list of files.
If file has changes or already in directory than diff button displayed.
On clicking diff button you can see changes in file.
From this model (window) you can modify file as your need or you can copy/paste code in/from temporary file and manage.
Simple way is regenerate model and crud after adding fields to table.
If you have modification in crud, you can generate in GUI files without saving and by copy paste move new column code.

How to add a new view (and also a new Menu Item Type) to existing joomla 2.5 components?

Maybe I want to add a new view, and also a new Menu Item Type to content component.
What are the steps please?
UPDATE
Question (by #ValentinDespa) :
You want to extend com_content functionality or you want to override a
view or to build a new component that does something?
As I said, I want to extend com_content and add a new view to it. There are some views like Single Article, Category Blog, and Category List right now.
I want to add another menu items called Article Titles, so titles only will be displayed but with some parameters (like columns count).
It is a need that is not supplied by current features.
NOTE
Guys, it doesn't matter what my new view should be like, please tell me How to create a new view.
Yes You can create a new view.
Its simple just copy any of the view (category,blog) from your com_content.
The file structure should be like inside the folder.
Step 1
view.html.php
tmpl
your layout names(default.php)
xml file.
Also remember to change the class name of the view.html.php
Step 2
Add a controller file (just make a copy of existing one category or blog)
Controller name must be your new view folder name.
Also remember to change the class name of the controller
step 3
add a model file for your new view (same make copy of any existing)
remember to change the class name and file name should be view folder name.
Then you can access this view by giving correct url.
eg: www.example.com/index.php?option=com_content&view=yourviewname&layout=yourlayoutnames.
Here I mentioned view folder name must be controller and model file name we can achieve with other name also but it will create problem for you when you are not good in joomla.
Note:
For adding a view you don't need to install a component its not a good idea at all.
Also You can add multiple layouts in a view
inside your tmpl folder just create new files.Also don't miss the controller and model to put in com_contents/controller and com_contents/model folder
for More help take a look at this

Add new entities in OpenCart

I was wondering if I can add new entities (classes/tables) in OpenCart to store information that is not included in the default functionality. To be more precise, I would like to add subscription (3/6/12 months) related information, as described here: OpenCart subscription model (x months)
If yes, can I just add admin pages for the new class? Would something like: How to create a custom admin page in opencart? work?
You would need to create a
Template file (.tpl)
Controller file (.php)
Model file (.php)
Language file (.php)
All files are named the same with different extensions and located in their respective folders
You will also need to add more columns in the database named with the additional settings you ant to store.
In addition to your page specific setup you will also need to add a link to your page in the header file, in the menu.
You will use the model file to insert, update and delete data within the database. The controller controls what functions within the model are used.
Once created, In admin/ user group permissions you need to give access o the new pages
Take a look at the existing files to see how it works. Make a copy of one of the more simpler 4 files, rename, then start to modify them.
If you only want to add more settings to a existing page then you can add them to the existing 4 files and add columns in the database.
Hope that helps get you started, Good luck!

Typo3: Is it possible to make a custom flexform for an extension?

I'm making an extension where the user is able to post posts. But I want the extension to be dynamic so that for example on one page the user can upload pictures where as on another page the user can not upload pictures but some text.
I want to be able to create a template for the plugins backend and one for the frontend that you can modify for each use of the plugin.
I know there is flexform but with that the user of the plugin has to modify the plugin...
Is is possible and if so, how can I do it?
You should be able to modify the TCA for the field pi_flexform before its rendered by using some of the existing hooks in the core methods, thus changing what XML file (containing flexform configuration) is loaded for your plugin. As this is page config, it can be different for each page but it can be inherited by subpages.
While class.t3lib_tceforms.php contains lots of hooks, I believe that for changing TCA on the fly you will have to use a different one: postUserLookUp in t3lib/class.t3lib_userauth.php.
Create a class that would contain method modifying TCA and register it in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['postUserLookUp'][] = 'EXT:YOUR_EXTENSION/class.YOUR_CLASS.php:YOUR_CLASS->YOUR_METHOD';
In your custom method override TCA for $TCA['tt_content']['columns']['pi_flexform']['config']['ds']['YOUR_EXTENSION_pi1,list'] by a value that your admin sets in a page config. t3lib_BEfunc::getModTSconfig() should let you load page config and it's up to you to decide what key you will be looking for.
NOTE: This is untested theory but its principle is based on one of my custom extensions where I modify TCA on the fly.
Have a look at EXT:flux. Claus did that already.
https://github.com/FluidTYPO3/flux

What's the best way to include custom HTML in a Symfony form?

I'm working with a Symfony generated admin and need to include some custom HTML into a form. This HTML (a label, img tag, and link) should only appear when the action is 'edit'. What's the best way to do this? It seems like I should just be able to include a partial, but I don't know where to include it from. Thanks.
Depending on the functionality you want the partial to have you could also write a custom widget and use your custom widget instead of the standard symfony one.
(I use this for a widget wich displays me various sizes of images after a file upload)
I think I found the solution:
I created a partial and set it to display within the moduel's generator.yml file (in the 'edit' section)

Categories