Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
is Custom Pages plugin working on Vanilla 2.6?
mroth7684
New
Hello,
I was using BasicPages plugin to add custom static pages to my vanilla forum website but it turns out I can't add modules to the content of basicpages.
I've downloaded Custom Pages to give that a try but I cannot get the link for it to show up in the admin dashboard so I'm not sure how to use it. I've deleted the cache folder and allowed it to rebuild but still not showing. Is this working in 2.6 or am I doing something wrong?
The goal is to add a landing page to my website that will be the new home/root page and will contain static content and then below the static content I want it to show the latest 5 discussions. What is the best way to achieve this?
0
Comments
I was just browsing the vanilla forum showcase and saw a couple websites that are basically doing what I want to do. https://community.acer.com/en/ and https://community.dentistry.com/
Are they using an application or plugin to do that or is it just a custom page with the categories and discussions module embedded? or would it be done in the theme and view template?
Update: I got custom pages plugin to work. I found an old comment that has a fix for newer vanilla forums.
However I would still like some help with how to get discussions to show on a custom page. I found a discussion that says to make a custom theme module and use the discussions module and view from vanilla core as the template. So if I do that and rename it to HomepageModule how would I then access the homepage module from the browser? I know how to add routes to shorten the URL to what I want but I am not sure of the path to use.
In theory it should be like this:
Save that into the root folder of your forum and if it's not working give feedback
R_J thank you for your post. I'm at work now but I will try out the code later today.
I'm assuming since you said to put the code in the root folder that I should name this file something like home.php? then I can set home.php as the path for forumroot in the routes settings.
Exactly like that
For some reason I could not get the page to display with the file in the forum root. "page not found" error.
However by adding the following code to my Custom Page plugin page the discussion module does show up.
<?php $discussionsModule = new DiscussionsModule(); echo $discussionsModule->toString(); ?>
However I see that the data displayed is minimal. I would like to get the rest of the data like author, avatar, and category. I see in the class.DiscussionsModule.php file that I'll need to add some of those functions to the custom page to do that. Or is there a better way to do it?
My apologies if this should be known. I'm familiar with python programming but PHP is new to me. I'm trying my best.
Not much time for explanations, sorry! The file attached is a short plugin which should basically work.
Vanilla uses a front controller which means that every file access is routed through the index.php file. Therefore something like "home.php" couldn't be found. Maybe it is better to realize this as a plugin.
You can reuse some parts of the plugin to show the html markup like it is used in the forum, but all the CSS is missing. You will have to work on it for sure. Maybe you should take a look at the writeDiscussion function and simply pick from it what you like.
Thank you again. I was able to install the plugin and render the custom page view with the theme and Recent Discussions information. Hopefully I can customize it from here now that I understand it a bit more.
Hi @R_J I'm wondering if you can help me with this one more time. I don't think the avatar and original author info for discussions is being returned. I enabled the built-in plugin to show original posters avatar on each discussion. But I am not seeing how I would make it work on the homepage discussions also. Here's my code so far the HomePage view is at the bottom, I can't figure out how to end the first code block:
HomePagePlugin.php
homepage.php view:
Recent Discussions
<?php foreach ($this->Data['HomePageDiscussions'] as $Discussion) { writeDiscussion($Discussion, $this, $Session); } ?>