I have created a snippet that takes specified code and minifies it, but I'm looking to turn this into a plugin to streamline the process. I'm looking to have the code minify when I save a file, and create a new file in that directory with a new name. I have this working as a snippet, but I don't want to be writing files every time the page is loaded.
Is there a way to check when a file (in the Files Tab/Assets) is saved in ModX, and then execute a plugin? I looked through the existing System Events, and didn't find anything.
Looks like you have 3 system events that may work for you: OnFileManagerUpload, OnFileEditFormPrerender & OnFileCreateFormPrerender. My guess would be OnFileManagerUpload.
Docs here:
http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins/system-events/onfilemanagerupload
Though it's important to note [the last time I checked] that even if a system event is listed in the manager and/or documented, they are not all implemented [i.e. won't work] - best to check on this in the modx forums or dig through the code to see if it actually exists.
Now, you are trying to do this from the manager or some front end form?
In the manager attaching a plugin to the OnFileManagerUpload hopefully works. In the front end you may have to attach your plugin to one of the page rendering events either read the file's time/date or append/prepend a timestamp within the file itself.
[or if you are using formit, you can probably use a custom hook to get the job done as well]
Related
In a website I'm working on, a javascript file (and a css too) gets downloaded even if the feature it's related with is not present on the page. Since that plugin doesn't allow to load the files only when needed, I wanted to use a wordpress hook to dequeue them when not necessary.
To know if this scripts are needed, I could check inside the html code if a specific element is present (using regex or another method), but I don't know which hook to use and how to get the html data. Could anyone show me how to do it or even just point me to some documentation about it?
WHMCS has a feature for providing downloads to clients. The feature can be found in their admin area at /admin/supportdownloads.php
Is there any action hook for when files are uploaded via the admin area? The only related hook I can find is for when files are downloaded.
What I want do to is add a hook so any file I upload is added to the list of Associated Downloads for each of my products. With all the hook options they have, I'm surprised I can't find one for this...
While I have not done exactly what you are trying to do, I can tell you that anything you put in the /includes/hooks folder gets executed, regardless of whether it is actually hooked into a specific point. This is incredibly useful for those moments where there aren't any hook points available (or they are documented as being present but not on certain page renders).
So in a php file in the /includes/hooks folder, I start by echoing out the globals variable. WHMCS stores a lot of information in the globals variable that easily permits you to deduce which page you are on. For example, in one of my hooks, I have a function that determines what the file name is that I am on simply by calling up get_filename(); That function checks the request URI and finds the php file being called. If the filename is one I'm looking for (for example 'dologin') I can isolate the code being executed. You continue to isolate based on the page you are looking for (for example, if each request has a certain variable, or requires being logged in you look for those variables).
Once you are sure you have to be on the page in order for the code to fire, then you can write your PHP to grab the form posted data and store it how you like in a secondary table. The only catch is if the form must first be stored into the database, so you need a unique identifier, but that can be gotten around also.
Hope that is of help...
I am trying to display the value of a custom field, already configured in Phabricator, on the task tile view in the Backlog workboard page.
I've been going through the documentation, and have found two suggestions for how to approach this - create a new library and import it with the 'load-libraries' option in the admin GUI. Or, create a php class in the src/extensions folder.
However, all the classes I want to extend are marked as 'final', so now I don't know how to customise e.g. ProjectBoardTaskCard::getItem() so that it fetches the additional property(ies) from the defined custom fields.
OK, this is possible!
We wanted a custom field 'points' to display (as in Agile story points) on each of the tiles in the workboard view, not just the task details page.
I downloaded this and extracted it along side phabricator (so I had /path/to/phabricator and /path/to/Sprint directories)
Then I edited the phabricator/conf/local/local.json
...
"load-libraries": [
"Sprint/src"
]
...
Whilst we had a custom field defined in our config, this plugin provided it's own Points field, making ours redundant.
after cleaning up the config, and running
arc liberate src/
in the Sprint folder for good measure (it has a composer file but we didn't need use it) then it just became a simple matter of updating the properties of the projects to get this working.
(you can see what the points on task boards look like at https://phab08.wmflabs.org/tag/sprint/ - and the burndown chart that comes with at https://phabricator.wikimedia.org/sprint/view/938/ if you signup for an account)
You need to enable the checkbox for isSprint in the project, save, then edit the project again to enable a start / end date for the sprint. Then your story points, burndown charts, list of sprint projects etc will begin to work
Even if you don't want 'sprint', this code has figured out how to pull the custom fields and display it in the workboards, as per the original problem, so I expect it would make a great starting point for someone!
The code available at https://github.com/wikimedia/phabricator-extensions-Sprint
I'm developing a web application where users can upload multiple plugins. I want to give an extra value to my app with a feature like wordpress plugin version adviser. I don't know how to deep in this area in order to investigate. I hear someting like "pingtracks", but not sure if this the correct way. Well, that's my doubt, how can I determinate if there is a new plugin version to uptade?
Thanks in advance.
PS: There is a table in my db with all plugins relevent data like url, author, current version, etc.
Each plugin should have a URL for some sort of update manifest. The resource at that URL should contain information such as currently available versions, and the URLs of files that need to be updated. This file could be as simple as static JSON data.
Please remember to use HTTPS, so that it is harder to spoof your update site.
Every time that user uploads a new plugin, check the "current version" in your DB and compare it with the last same-named plugin uploaded. (create another table for saving needed data for example)
My codeigniter app is multilingual and I want to redirect users to their pages, by checking IP address.
I should check it at the top of all pages (i know i can set a session or cookie, but i want to check it on all pages); before any views or other.
Where should i put my code (function)? on Startup file or Loader? or create an extension or plugin and load it on Startup? if it can be done by an extension or plugin, how can I create it? (i've searched, but didn't find a useful tutorial)
Thanks.
If you're using a main front controller you can put your code in there. But a better way to do it would be to use CodeIgniters built in functionality to extend the core - hooks!
http://codeigniter.com/user_guide/general/hooks.html
Just select the point you want your script to be activated and take it from there.