XF 1.1 How do I set Parent node to 'Media tab', for created pages which default to Forum tab?

CritiKiL

Active member
This is what you've helped me do with the Pages.php script (w/edits):
Code:
<?php
 
/**
* Route prefix handler
*/
class XenForo_Route_Prefix_Pages implements XenForo_Route_Interface
{
    /**
    * Match a specific route for an already matched prefix.
    *
    * @see XenForo_Route_Interface::match()
    */
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $request->setParam('node_name', basename($routePath));
 
        if (in_array($request->getParam('node_name'), array('clancast', 'kilplixtv', 'clankill_tv', 'ufreqtv')))
        {
            $section = 'media';
        }
        else if (in_array($request->getParam('node_name'), array('warroom-1', 'pws-1', 'ezStats2')))
        {
            $section = 'xboxlive-leaderboard';
        }
        else if (in_array($request->getParam('node_name'), array('psngames', 'psnplayers')))
        {
            $section = 'xboxlive-leaderboard';
        }
        else if (in_array($request->getParam('node_name'), array('useralbums', 'useralbums/create', 'useralbums/own')))
        {
            $section = 'media';
        }
        else
        {
            $section = 'forums';
        }
return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', $section);
}
 
    /**
    * Method to build a link to the specified page/action with the provided
    * data and params.
    *
    * @see XenForo_Route_BuilderInterface
    */
    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, 'node_name');
    }
}
 

DRE

Well-known member
Right when I was about to go to bed I see this little piece of awesomeness. Jake you the man! And thank you Critikal! I had been too lazy to ask this question myself
 

DRE

Well-known member
Let's change it up a bit for more conditions:

Rich (BB code):
/**
* Match a specific route for an already matched prefix.
*
* @see XenForo_Route_Interface::match()
*/
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
$request->setParam('node_name', basename($routePath));
 
if (in_array($request->getParam('node_name'), array('clancast', 'clankill_tv', 'ufreqtv')))
 {
 $section = 'media';
 }
 else if (in_array($request->getParam('node_name'), array('warroom-1', 'pws-1')))
 {
 $section = 'xboxlive-leaderboard';
 }
 else
 {
 $section = 'forums';
 }
 
return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', $section);
}
I tried this and it's not working. This is my code in public_html/library/XenForo/Route/Prefix/Pages.php


Code:
<?php
 
/**
* Route prefix handler
*/
class XenForo_Route_Prefix_Pages implements XenForo_Route_Interface
{
    /**
    * Match a specific route for an already matched prefix.
    *
    * @see XenForo_Route_Interface::match()
    */
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        if (in_array($request->getParam('node_name'), array('pixlr-editor', 'pixlr-express', 'pixlr-o-matic')))
        {
            $section = 'useralbums';
        }
        else if (in_array($request->getParam('node_name'), array('world-time-map', 'chatbox')))
        {
            $section = 'members';
        }
        else
        {
            $section = 'forums';
        }
 
        return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', $section);
    }
 
    /**
    * Method to build a link to the specified page/action with the provided
    * data and params.
    *
    * @see XenForo_Route_BuilderInterface
    */
    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, 'node_name');
    }
}
Sample page: http://www.8thos.com/pages/pixlr-editor/
 

DRE

Well-known member
Okay I added it, and still not working.

Code:
<?php

/**
 * Route prefix handler
 */
class XenForo_Route_Prefix_Pages implements XenForo_Route_Interface
{
    /**
     * Match a specific route for an already matched prefix.
     *
     * @see XenForo_Route_Interface::match()
     */
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $request->setParam('node_name', basename($routePath));
        if (in_array($request->getParam('node_name'), array('pixlr-editor', 'pixlr-express', 'pixlr-o-matic')))
        {
            $section = 'useralbums';
        }
        else if (in_array($request->getParam('node_name'), array('world-time-map', 'chatbox')))
        {
            $section = 'members';
        }
        else
        {
            $section = 'forums';
        }

        return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', $section);
    }

    /**
     * Method to build a link to the specified page/action with the provided
     * data and params.
     *
     * @see XenForo_Route_BuilderInterface
     */
    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, 'node_name');
    }
}
 
R

ragtek

Guest
1. Start debugging;)
Use an debugger with some breakpoints and check the params or add die($request->getParam('node_name') command to your script so you know why it's not working

2. you shouldn't change the original file;)
Use the event listener system^^
 

DRE

Well-known member
1. Start debugging;)
Use an debugger with some breakpoints and check the params or add die($request->getParam('node_name') command to your script so you know why it's not working

2. you shouldn't change the original file;)
Use the event listener system^^
Is your reply for me or the original thread starter?
 

DRE

Well-known member
For you;)

You also have the enhanced pages(if you have the add-on^^), you could check the code from Ragtek_PC_Route_Page
It's "the same..;)"
Yeah I am using enhanced pages. So I gotta do it in your library then? I forgot I was using it. Your enhanced pages addon is one of the most useful addson the site. I like that member's can comment pages. Could you consider adding a rating feature like 1 to 5 stars? Kinda like how it's setup in the resource manager.
 

DRE

Well-known member
yes


let's wait to release finally all the stuff at robbos page and import the premium users..:D then you can start requesting features again:p
What happened to your website? I tried signing on so I could download it again cause even though I have it on my server, I have no idea what folder it is because of the two or three letter abbreviations you use for your different addon names inside the Ragtek library folder.
 
R

ragtek

Guest
What happened to your website? I tried signing on so I could download it again cause even though I have it on my server, I have no idea what folder it is because of the two or three letter abbreviations you use for your different addon names inside the Ragtek library folder.
i was hacked and "somebody"(already know who) deleted everything and he also "deleted/canceled" all my domains....
That's why there's now much more stress with moving everything to merc as soon as possible:(
And after all this i'm not interessted anymore in doing anything, so i don't want to get the domain back and start again...
 

DRE

Well-known member
i was hacked and "somebody"(already know who) deleted everything and he also "deleted/canceled" all my domains....
That's why there's now much more stress with moving everything to merc as soon as possible:(
smh. What goes around, comes around. Karma will get him eventually.

Can you recognize which addon folder is Enhanced Pages in that screenshot I posted?
 
R

ragtek

Guest
pc (because it started as "page comments")

but thx for this, i'm having this already on my dev board and probably i should add the add-on name in some file inside of the add-on directory too^^
 

Attachments

DRE

Well-known member
pc (because it started as "page comments")

but thx for this, i'm having this already on my dev board and probably i should add the add-on name in some file inside of the add-on directory too^^
Ah okay thank you and your welcome! I thought PC was Personal Conversations related.
 
R

ragtek

Guest
yea, my naming system isn't really good, but my whole system is built on this(developer tools, addon builder, test suite..), so i can't change it really easy^^
 
Top