FSPHosting
New member
Hello,
I'm attempting to get Navigation Links via the API, to use for integration to a third party website. However, the content that is returned is challenging to work with. Im currently running the following code in my API:
This is generating me the following (3 different keys):
I'm struggling to work out how to turn "{$xf.homePageUrl}" and "{{ link('forums') }}" into actual links. My external site is not accessing XenForo directly (via files) so cannot use any templating.
Any help would be much appreciated.
I'm attempting to get Navigation Links via the API, to use for integration to a third party website. However, the content that is returned is challenging to work with. Im currently running the following code in my API:
PHP:
/** @var \XF\Repository\Navigation $navRepo */
$navRepo = $this->app->repository( 'XF:Navigation' );
$navTree = $navRepo->createNavigationTree();
$data = $navTree->getDescendants();
foreach ($data as $key => $navItem) {
print_r("Key: " . $key . "\r\n");
print_r("Title: " . $navItem->getTitle() . "\r\n");
print_r("Link: " . $navItem->getValue("type_config")['link'] . "\r\n");
print_r("Parent ID: " . $navItem->getValue('parent_navigation_id') . "\r\n");
}
This is generating me the following (3 different keys):
Key: home
Title: Home
Link: {$xf.homePageUrl}
Parent ID:
Key: forums
Title: Forums
Link: {{ link('forums') }}
Parent ID:
Key: newPosts
Title: New posts
Link: {{ link('whats-new/posts') }}
Parent ID: forums
I'm struggling to work out how to turn "{$xf.homePageUrl}" and "{{ link('forums') }}" into actual links. My external site is not accessing XenForo directly (via files) so cannot use any templating.
Any help would be much appreciated.