All!
As the title says, I am new to deal with Drupal and I need to make a module that sends emails whose content is based on HTML and preferably using Twig templates. At the same time, these messages are sent by triggering them through restful web services.
I know how to create a custom module, but I have not dealt with Twig templates and I do not know how to read them in the code and how I can inject data into their placeholders.
I have read about some ways to send e-mails programmatically through Drupal and I did not understand well. An example of this is the use of the hook_mail(). What I understood is that I have to make a custom module and then use this function with the word hook replaced with the name of the module and then make a function that uses the mail manager in Drupal \Drupal::service('plugin.manager.mail'), but what I don't understand is where to put that hook_mail() function inside the custom module?!!! Is it in a PHP file inside The src folder and where is inside the src folder?!!!. What I know is that if I make a special Form that I have to put its PHP file inside the Forms folder, which is inside the src folder. So where do I put it? Is the mail manager, \Drupal::service('plugin.manager.mail'), inside Drupal built internally or is it an external plug-in that has to be installed? Does it support HTML messages?
Best Regards,
Amr Rashad
Related
I'm trying to add some extra functionality to the site creation form of Alfresco 5 by creating a web script. I'm creating a jar file containing the module extension.
I have successfully modified the actual site creation for by adding a new site type (this was done for testing purposes only). I did this by adding the following to the extension-module.xml file:
<module>
<id>Create Site Extension</id>
<version>1.0</version>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.modules</targetPackageRoot>
<sourcePackageRoot>create-site</sourcePackageRoot>
</customization>
</customizations>
</module>
/config/alfresco/web-scripts/create-site.get.js
model.sitePresets.push({
id: "site-test",
name: "TEST"
});
When added to tomcat/webapps/share/WEB-INF/lib and activated through the Alfresco module management page it works perfectly. I can see TEST in the list of site types.
I'm trying to do the exact same type of thing but with create-site.post.json.js. No matter what I do, I can't get my create-site.post.json.js web-script to fire. Is it possible to extend the .post.json.js file for create-site?
UPDATE
In case anyone wants to look at the raw source, here it is: Module Srouce
Everything in the module works correctly except for the create-site.post.json.js. I know for a fact that the deleteDashboard method inside the .post.json.js file works correctly and it's what I've been using to attempt to debug the script (in case the debugger was running it but not breaking into it for some reason. If it runs, it should delete the test site "good-site"'s dashboard so if it worked, the dashboard will be empty/nonexistent.
The issue is obvious. Because you are using extension module and overriding out of box webscript. Now if you change the type of webscript from get to post it will not override it. So, if you really want to replace out of box webscript with yours then you need to get to the point where this component is called and override that. You will also require to create full post webscript (all related files)
I'm building a site starting from the magnolia empty webapp with maven.
All is ok but now I'm now writing the contact page of the site. I'd like to use the magnolia mail module for this. So I installed the mail module and the form module.
Problem:
After installing the form module in magnolia 5.4, the template called "Form" does not appear in the template selection when creating a new page in the pages app.
As it seems from the Documentation, it should be there.
Details:
Other templates, created by me with yaml and freemarker, correctly appear (and i can use them correctly).
The mail module is up and running and configured: i can send a mail to myself with the "verify setting" page, using a template i made, but i'd like to create a contact module for my site.
I installed the module with maven like:
dependency: groupId:info.magnolia, artifactId:magnolia-module-form , version:2.3
and installed it with the usual steps (installed module, wait , correctly completed without messages, started magnolia)
I DO NOT have STK installed since i'm using MTE... and i've other modules installed (resources, site, mail, MTE, DAM, etc...)
Am I missing something or doing something wrong? :|
Otherwise, Can the magnolia mail module simply be used standalone without the form module to send out a email, may be pointing a hand-written form to somewhere?
Or, best option imho: can I make a new form template with yaml? I can't find docs about it.
Thank you!.
Edit: I tried to install the STK along with MTE (I correctly updated to magnolia 5.4.1) but it relies on data-module 2.3.6 (which i don't have in my dependencies and which i don't use) so it won't install the STK. Also , installing STK just for a form template seems overkill to me. I'd prefere to understand how to insert a form in one of my templates.
Preinstalled templates are for STK. If you want to use Magnolia without STK, then you need to write template yourself, but in exchange have much more freedom in what you can do with that template. Once you create and register template you should be able to use it.
Re STK - latest version doesn't have any dependency on data module - see module descriptor. Either I'm blind or there is no such dependency. :D
HTH,
Jan
We have legacy code to maintain and, to solve a specific customer customization problem, we want to route calls to some files to other files. That is, when the app calls a particular ASPX, it will end up hitting another ASPX.
If you call:
www.foo.com/admin/admin.aspx
It will actually hit:
www.foo.com/customizations/customer1/admin/admin.aspx
This is not a good design but this is legacy code. We just want to solve this.
We are using the System.Web.Routing framework to solve it. This works fine when you set RouteExistingFiles to true, except for static files (CSS, JavaScript and Images).
When I first tried it, it retrieved this error:
There is no build provider register for the extension '.css'.
So I did register a build provider in the web.config file for the .css extension. I used this build provider: PageBuilderProvider because someone recommended it in the internet.
It works! But the CSS is being served with text\html content type.
How do I achieve this?
TL;DR: I want to use routes in ASP.NET Web Forms to make a call for a specific CSS file to actually retrieve another one. A customer needs this for customization.
Try coding a HttpHandler. I had to do something similar but for PDF files, I coded a custom HttpHandler in the end - works very well. You can even set the content type in the HttpHandler code and have a pattern matched path the handler will be used for in the web.config. You can also configure it in web.config not to execute if the path does not point to an existing file e.g. so a 404 is returned without having to code that in the handler itself. I can't post my code (VB.NET) ATM because I'm using a tablet but google search for tutorials. You will also probably need to use the TransmitFile function to actually write out the css file. Is it a web forms project or web site? If its a web site there is a special way of registering the HttpHandler in the web.config.
I am trying to hook into the Wordpress file uploader and would like some suggestions. I would like to be able to grab the path of the source file (not WP path; i.e. K:\docs\file.pdf) so I can download another file of the same name (different extension) & path automatically (i.e. K:\docs\file.txt).
Wordpress provides hooks for after the file is uploaded but all path information at that point is internal to wordpress.
Thanks in advance!!
the path information can be obtained from normal php functions like pathinfo() and realpath() for example .
Bit too late to the party but I think what you are asking for is to find the source of the document in the clients system and based on that you want similar files there to be picked up by the browser and then sent to the user.
I think it will be a fairly complex thing to do, firstly you have to get the source of the document being added to the browser (I am not sure it can be done, but if it can be done then it will be via javascript) and then upload all the files one by one to the server hosting wordpress and you can do this by creating a custom page which will add the files uploaded to it as a wordpress attachment and then using something like jquery file uploader to upload files to that location.
But honestly, I think it would be a very complex thing, unless the client and the server are on the same machine.
I want to store PDF and Image files in Drupal. By default Drupal seems to store binary/uploaded files into the filesystem. I want to to be able to store files so that - I can have workflows, metadata, IP information and URL aliases?
Update, am still stuck at how to create URL aliases for files on the file system. Drupal only seems to allow creating URL aliases to node content.
The simplest solution for Drupal is to use the Upload module, which is in core. The upload module allows you attach files to nodes. As you note, they are stored in the filesystem.
If you want to get more complex, you can build your own content types through the web interface by using the CCK family of modules (such as the filefield module or the imagefield module). Your files are still stored on the filesystem.
You could use CCK to create the metadata field you want.
You could use the workflow or rules modules to implement workflow.
IP information is recorded automatically by Drupal's logging module (either the database logging module, which logs to the database, or the syslog module, which logs to syslog).
URL aliases for nodes are available in core Drupal by enabling the path module (or download the pathauto module for automatic creation of aliases).
I tried Drupal's Upload module, FileField as well as uploading files using FCKEditor - I prefer the last one - it is closer to my specific scenario.
Creating an alias to the file will likely require some custom code.
It's not possible to simply create an alias using the Administer > Site building > URL aliases screen. I tried inserting a record with
insert into url_alias (src, dst) values ('sites/default/files/ChipotleArt.JPG', 'here-is-the-file.jpg');
That still didn't work. So, you will really likely need to write some custom code.