New video series: Building with XenForo 2

A long time ago, in a forum not particularly far, far away (may the fourth be with you), we produced a series of videos showing off how easy it was to build rich pages with XenForo's templates and javascript framework.

While many of the principles demonstrated in these videos remain a key part of XenForo 2, most of the syntax employed by XenForo 1 back then has changed, and there are many more tools at your disposal, like entities and command-line functions.

Building with XenForo 2


Alongside the release of XenForo 2.2.5, it seemed a good time to put together a new series, rounding up all of the key parts of XenForo add-on development, starting with the basic steps of creating a new add-on and moving on to the template system, working with the database using finders and entities, creating and editing content, putting together paginated lists of content items and extending existing classes to add new functionality.

We hope that the videos have something for everyone, from those who are only just starting to think about building with XenForo to those who have been doing so for ages, and may even trigger the realisation that XenForo is not solely a platform upon which add-ons for XenForo can be built, but rather a community framework, capable of acting as the foundational layer for rich community applications in their own right.
Video series logo - Building with XenForo 2
Parts one and two of the series are released today, with parts three and four to follow tomorrow.

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

On Thursday, as part of XenForo Insights Episode 6 (9am US Central, 3pm UK time via Zoom) we'll have a live recap of the steps so far, and a look ahead to what's in parts five and six, which will be posted immediately following the webinar.

Further parts of the series will be released in the coming days.

Each new part posted will be added to the Building with XenForo 2 playlist.

If you have any comments or suggestions, please post them here in this thread rather than over at YouTube so we can handle them like other content posted here and ensure that they receive the attention they require. As always, requests for technical support should be directed to the appropriate forum.

Here is a list of the videos in the series, which we'll keep updated as new parts are published:
  1. Getting started
  2. Creating and linking test pages
  3. Passing variables to templates
  4. Working with the database - entities and finders
  5. Creating a custom entity
  6. Creating, editing and saving content
  7. Building a form
  8. Listing your content
  9. Paginating your content lists
  10. Class extensions and self-to-many relations
  11. Implementing inline editing with the XF javascript framework
  12. Utilising the Delete controller plugin
  13. Working with permissions
  14. Implementing Reactions
  15. 2022 series...
 
Last edited:
Thank you @Kier I've just watched the new XenForo architecture video.

This is really informative and helpful.
I think that these videos will make it so much easier to invite and on-board new developers. Something that has always been a struggle.

I hope that you will keep this coming.
 
Today, we're delving into permissions in part 13.

The permissions system in XenForo is one of its crown jewels, so of course you're going to want to have fine-grained permission controls for your add-on products. This video takes you step-by-step through the process and best practices.

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
 
If you've ever created a custom content type within XenForo you may have been tempted to add reactions (or formerly Likes) to them but perhaps been concerned that it might be difficult to implement them with your custom code, but if so, your fears were unwarranted.

Reactions are a great way to improve user engagement and interaction, so let's add them to our notes! You may be surprised at just how quick and easy it is to do.

In fact, here in Part 14 of Building with XenForo 2, we implement reactions for our notes content items in just over twenty minutes, including the time it takes for @Kier to waffle on about technical details!

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

Necessarily, this video also touches on the use of content type fields to provide the reaction_handler_class identification for the demo_pad_note content type...
 
Another idea from me. Attachments

Ice Hockey Reaction GIF by NHL
 
Please consider to do a video on integrating a payment method? I think this would be valuable. It will lead to more payment gateways being added to XF.
 
Could you make the source code available, please? I'm stepping through the tutorial and finding it difficult to see the video and would be nice to check for key errors against the source.

Also on part 5 adding PhpDoc i get the following error:

1627924648691.webp


1627924689161.webp


Is this down to composer not being setup correctly in phpstorm?
 
UI dependencies.

eg, "add new X" in a modal has a drop down option.
How to 'add new item to dropdown' with another modal link to that option's form.

eg,

Code:
<select>
<option>A</option>
</select> <a href="#modal">Create new Option B</a>

clicking that link pops modal B create form on top.
Saved, and modal closes and option B gets Dom-added to the select.
 
Hi @Kier
These are very wonderful videos,
I'm looking for ward to see new video for adding photos/attachments to notes.

Thank you so much.
 
If you've ever created a custom content type within XenForo you may have been tempted to add reactions (or formerly Likes) to them but perhaps been concerned that it might be difficult to implement them with your custom code, but if so, your fears were unwarranted.

Reactions are a great way to improve user engagement and interaction, so let's add them to our notes! You may be surprised at just how quick and easy it is to do.

In fact, here in Part 14 of Building with XenForo 2, we implement reactions for our notes content items in just over twenty minutes, including the time it takes for @Kier to waffle on about technical details!

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

Necessarily, this video also touches on the use of content type fields to provide the reaction_handler_class identification for the demo_pad_note content type...
This implementation gives a small error when push notifications are enabled. Does anybody know what the fix is for this please?

Error:
  • Error: Call to a member function getPushTemplateName() on null
  • src/XF/Service/Alert/Pusher.php:53
  • Generated by: Lee
  • Jan 5, 2022 at 12:58 AM

Trace:

Stack trace​

#0 src/XF/Service/PusherTrait.php(187): XF\Service\Alert\Pusher->getNotificationBody()
#1 src/XF/Repository/UserAlert.php(163): XF\Service\Alert\Pusher->push()
#2 src/XF/Repository/UserAlert.php(101): XF\Repository\UserAlert->insertAlert(3, 1, 'Lee', 'tls_thoughts_th...', 22, 'reaction', Array, Array)
#3 src/XF/Reaction/AbstractHandler.php(186): XF\Repository\UserAlert->alertFromUser(Object(SV\ReportImprovements\XF\Entity\User), Object(SV\ReportImprovements\XF\Entity\User), 'tls_thoughts_th...', 22, 'reaction', Array)
#4 src/XF/Repository/Reaction.php(201): XF\Reaction\AbstractHandler->sendReactionAlert(Object(SV\ReportImprovements\XF\Entity\User), Object(SV\ReportImprovements\XF\Entity\User), 22, Object(TLS\Thoughts\Entity\Thought), 1)
#5 src/XF/Repository/Reaction.php(142): XF\Repository\Reaction->insertReaction(1, 'tls_thoughts_th...', 22, Object(SV\ReportImprovements\XF\Entity\User), true, false)
#6 src/XF/ControllerPlugin/Reaction.php(65): XF\Repository\Reaction->reactToContent(1, 'tls_thoughts_th...', 22, Object(SV\ReportImprovements\XF\Entity\User), true)
#7 src/XF/ControllerPlugin/Reaction.php(19): XF\ControllerPlugin\Reaction->actionToggleReaction(Object(TLS\Thoughts\Entity\Thought), 'thought/reactio...', 'thought')
#8 src/XF/ControllerPlugin/Reaction.php(12): XF\ControllerPlugin\Reaction->actionReact(Object(TLS\Thoughts\Entity\Thought), 'thought', 'thought/react', 'thought/reactio...')
#9 src/addons/TLS/Thoughts/Pub/Controller/Thought.php(149): XF\ControllerPlugin\Reaction->actionReactSimple(Object(TLS\Thoughts\Entity\Thought), 'thought')
#10 src/XF/Mvc/Dispatcher.php(350): TLS\Thoughts\Pub\Controller\Thought->actionReact(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('TLS\\Thoughts:Th...', 'React', Object(XF\Mvc\RouteMatch), Object(TLS\Thoughts\Pub\Controller\Thought), NULL)
#12 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(TLS\Thoughts\Pub\Controller\Thought), NULL)
#13 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2344): XF\Mvc\Dispatcher->run()
#15 src/XF.php(512): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}
 
How did PhpStorm inserted the namespace once the class is created? This is not working on my end, I needed to type that manually.

Any idea @Kier
 
How did PhpStorm inserted the namespace once the class is created? This is not working on my end, I needed to type that manually.

Any idea @Kier
 
Could you make the source code available, please? I'm stepping through the tutorial and finding it difficult to see the video and would be nice to check for key errors against the source.

Also on part 5 adding PhpDoc i get the following error:

View attachment 255532

View attachment 255533

Is this down to composer not being setup correctly in phpstorm?
Did you every get an answer to this, I'm having the same issue on Step 5? Thanks
 
Top Bottom