Node-based Contact Page

Foxtrek_64

Active member
Using Nodes as Tabs and a Page Node, I have created an HTML form...

The basic flow is as follows:

Code:
Your email field

Category field (determines recipient)

Subject

Message

I would like to know a couple things....

First, the Message field is a <textarea> currently. Would it be possible to replace this with the built-in WYSIWYG editor so senders can send (safed) HTML emails?

Secondly, would I be able to hook in with Xenforo's built-in email system or will I need to write my own php portion to handle passing off the form information to my Microsoft Exchange server?

Thanks
 
Hello,

You can't have a wysiwyg editor with pure HTML.
Some code is needed on PHP side, inside the view, to create the editor.

About the second part, not sure what you meant by passing the form information to your Microsoft Exchange server, is that a mail you want to send or something else ?

Clément
 
Hello,

You can't have a wysiwyg editor with pure HTML.
Some code is needed on PHP side, inside the view, to create the editor.

About the second part, not sure what you meant by passing the form information to your Microsoft Exchange server, is that a mail you want to send or something else ?

Clément


If I remember correctly, you can place PHP on the node through the settings page, though I haven't been in the admin panel since I asked this question so I don't quite remember.

As far as the second part, all PHP email scripts (that I have seen) require you to point to and provide the username and password required to access an SMTP server, whether that's Exchange, Ice Warp, or some other option. XenForo appears to have some email sending functionality built in (for validation of new accounts and such), though they may be calling back to smpt servers at xenforo.com to do this. I'm not entirely sure...
 
Ah perhaps but I am unsure that you can get the editor from that php code as it needs to be done inside the view.
I have never used nodes in tabs so hard to say.

No no the mail functionality uses your server so you could use that to send the mails.

Honestly I would personally do separate add-on for such purpose, not using nodes as tabs.
 
Ah perhaps but I am unsure that you can get the editor from that php code as it needs to be done inside the view.
I have never used nodes in tabs so hard to say.

No no the mail functionality uses your server so you could use that to send the mails.

Honestly I would personally do separate add-on for such purpose, not using nodes as tabs.


Nodes as Tabs allows you to place buttons to Xenforo nodes on the navbar at the top and doesn't relate to the question. However, thanks for clarifying the mail functionality.

What I'd really like to do with this page is limit what I need to write by using what already exists. I'm not very familiar with php - I'm a C# developer. The two tasks I'd like to accomplish, if at all possible, is including the WYSIWYG editor found when you're replying to the thread, and implementing the built-in email calls...

With the WYSIWYG editor already built and in place, I'd hate to have to write my own from the ground up and have to handle parsing html and such... is there a way to use a module or something of the sort that adds it in? Like I said, php is foreign to me... I can read it, but I can't write it.

Is there a mailer class so I don't have to write the functionality myself? For instance...

Code:
Mailer mailer = new Mailer();
mailer.to = support@website.com
mailer.from = TextBox1.text;
mailer.subject = TextBox2.text;
mailer.body = TextBox3.text;
mailer.send();
 
As I said for the wysiwyg I don't know if that's feasible with nodes as tabs, for that you should ask the add-on's author.

Yes for sure there is a helper function to send email.
Look at this add-on:
https://xenforo.com/community/resources/weekly-digest.3777/

Open the library/Andy/WeeklyDigest/CronEntry/WeeklyDigest.php file and you will see how it's used.

Thanks for your help on the email again.

But as I'd stated in my previous reply, the Nodes-As-Tabs plugin has no relevance to this question. All that it does is allow you to put links in the [home][forum][media] bar. I have a custom link pointing to my node page; that's all.

This question is in regards to placing Xenforo's built-in wysiwyg editor on a Xenforo page node. I would like to avoid having to re-invent the wheel, especially since Xenforo has a built-in way to handle bbcode. The less I have to "do over," the better. Additionally, it would be nice to be able to see if I can snag the code from the preview generator and send that...

When I click the "preview" button when submitting a thread, what function is called to process the output? Does it handle dumping the output to the page itself or does it just return a formatted HtmlWriter object (formatted HTML string that doesn't need to be parsed)? Is this the same function that processes the bbcode for posting the thread/reply to the forum?
 
There is indeed a generic function to parse bbcodes.

If you want to view how both the editor and the bbcode parsing is performed you could look at the library/XenForo/ViewPublic/Thread/View.php file.
The first part parses the bbcode and the second creates the wysiwyg editor for the quick reply.

To show an editor on a node page, I think you would have to extend the XenForo_ViewPublic_Forum_View class, renderHtml method, then you would have to add the editor your created integrated to a template that is included by that particular node.
From the editor creation shown on that page, you will not have to include that bit :
PHP:
                array(
                    'autoSaveUrl' => XenForo_Link::buildPublicLink('threads/save-draft', $this->_params['thread']),
                    'json' => array('placeholder' => 'reply_placeholder')
                )

To explain the different params, $this should not be changed, $draft is where the function should take existing data, 'message' is the index in the $draft array where the function should take the existing data.

If you never did code an add-on for xF, you could look at this tutorial:
https://xenforo.com/community/threads/creating-an-addon.5416/
As you are a developper from another language I am pretty sure you will understand, I myself was a C developper when I started coding in php.

Regarding your last question about the preview, I think it's handled by the controller action actionCreateThreadPreview in library/XenForo/ControllerPublic/Forum.php.

Clément
 
Back
Top Bottom