charlesfoote13
Member
Hello, I have a query regarding creating a new page. I want to create a custom page and what to use the database query to fetch the data from database
<div class="block">
<div class="block-container">
<div class="block-body block-row">
<div class="bbWrapper"><div class="bbTable">
<table border="1" cellpadding="2" cellspacing="2">
<xf:foreach loop="$catinfo" value="$catinfo">
<tr>
<td colspan="4">
<div align="center">
<h1>{$catinfo.cat_name} - {$catinfo.cat_description}</h1>
</div>
</td>
</tr>
<tr>
<td colspan="4">
<strong>HISTORY:</strong><br />
Formed for service in Northern Ireland<br />
absorbed into new regiment 6.4.2005<br />
Special Reconnaissance Regiment<br />
HQ Hereford<br />
formed to act as intelligence for Special Forces<br /><br />
I have also included<br />
Force Research Unit (FRU),Intelligence Corps<br />
formed 1980/81 to handle agents in Northern Ireland</td>
</tr>
<tr>
<td width="25%"><strong>Roll Of Honour: <a href="index.php?forums/roll-of-honour.4/&prefix_id=1&order=title&direction=asc">{$catinfo.cat_stats_roll}</a></strong></td><td width="25%"><strong>Awards: <a href="index.php?forums/awards.5/&prefix_id=1&order=title&direction=asc">{$catinfo.cat_stats_awards}</a></strong></td><td width="25%"><strong>Images: <a href="index.php?media/categories/14th-intell.52/&order=title&direction=asc">{$catinfo.cat_stats_images}</a></strong></td><td width="25%"><strong>Links: {$catinfo.cat_stats_links}</strong></td>
</tr>
</xf:foreach>
</table></div></div>
<strong>Web Links:</strong><br />
<xf:if is="$links">
<xf:foreach loop="$links" value="$links">
<xf:if is="$xf.visitor.is_admin"><span style="float:right">[ <em>{$links.link_hits} Hits</em> ]</span></xf:if><strong>• <a href="{$links.link_url}" target="_blank">{$links.link_name}</a></strong> - {$links.link_description}<br />
</xf:foreach>
<xf:else />
There are no links<br />
</xf:if>
<strong>Recommended:</strong><br />
<table border="0">
<xf:if is="$amazon">
<xf:foreach loop="$amazon" value="$amazon">
<tr>
<td width="70"><img src="store/tb_{$amazon.amazon_filename}" alt="{$amazon.amazon_productname}"></td>
<td><strong><a href="https://www.amazon.co.uk/gp/product/{$amazon.amazon_asin}/ref=as_li_ss_tl?ie=UTF8&tag=specialforces0a-21&linkCode=as2&camp=1634&creative=19450&creativeASIN={$amazon.amazon_asin}">{$amazon.amazon_productname}</a></strong><br />By {$amazon.amazon_author}<xf:if is="$xf.visitor.is_admin"><br /><em>{$amazon.amazon_clicks} Clicks</em></xf:if></td>
</tr></xf:foreach>
<xf:else />
<tr>
<td colspan="2">No recommended items added to this category.</td>
</tr>
</xf:if>
</table>
<xf:widget key ="images1014thintell"/>
</div></div></div>
<xf:widget key ="threads1014thintell" position="sidebar"/>
<?php
namespace Site\Pages;
/**
* Static methods for the Providers page.
*/
class CatFiftyTwo
{
/**
* @param \XF\Pub\Controller\AbstractController $controller
* @param \XF\Mvc\Reply\AbstractReply $reply
*/
public static function getData(
\XF\Pub\Controller\AbstractController $controller,
\XF\Mvc\Reply\AbstractReply &$reply
) {
if ($reply instanceof \XF\Mvc\Reply\View) {
////
////LINKS
////
$links = \XF::db()->fetchAll(
"SELECT
link_id, link_catid, link_name, link_description, link_added, link_url, link_hits
FROM craig_links WHERE link_catid = 52
ORDER BY link_name ASC
"
);
$reply->setParam('links', $links);
////
////PRODUCTS
////
$amazon = \XF::db()->fetchAll(
"SELECT
amazon_id, amazon_rohcat, amazon_productname, amazon_author, amazon_asin, amazon_description, amazon_clicks, amazon_filename
FROM craig_amazon WHERE amazon_rohcat = 52
ORDER BY amazon_productname ASC
"
);
$reply->setParam('amazon', $amazon);
////
////CATEGORIES
////
$catinfo = \XF::db()->fetchAll(
"SELECT
cat_id, cat_name, cat_xenname, cat_description, cat_history, cat_stats_roll, cat_stats_awards, cat_stats_links, cat_stats_images
FROM craig_categories WHERE cat_id = 52
ORDER BY cat_name ASC
"
);
$reply->setParam('catinfo', $catinfo);
}
}
}
?>
class CatFiftyTwo
TEST TEXT
<xf:foreach loop="$catinfo" value="$catinfo">
Username : {$catinfo.username} {$catinfo.email}<br />
</xf:foreach>
TEST TEXT
$finder = \XF::finder('XF:User')->where('user_id', '<', 100);
$catinfo = $finder->fetch();
Can you be a little more specific on what you want to achieve? I see from your screen shot you have "Front Pages" set in your nav bar, what else did you want, to set it under the forums tab?Hello,
Can you please let me know how did you manage to get the result at front? I mean, how did you get the menu to show at the menu bar at front? Can you please share the screenshot of the public navigation page as well, so that I'll get to know If I am making any mistake there.
I have also create a file with usertest.php on same path.
View attachment 229518
I also made the changes in previous code as per Lawrence reply, but no luck. I think I am doing some mistake with the public navigation to get the menu.
Can you please share the screenshot of public navigation where you managed to show this as your page menu?
View attachment 229519
This is what I have done in the public navigation menu. So at front my menu is visible as Front page.
View attachment 229520
Am I doing something wrong here? Please suggest
Here is the code I used for my testing:Hello,
I just want to create a new page from Admin , that new page should be visible in front end as a new menu and clicking on it I want to show the users and email from the Admin.
I am not sure where I am doing the mistake.
For this I followed following steps:
1) Created a new file at path "src\addons\Site\Pages\CatFiftyTwo.php" with following code:
<?php
namespace Site\Pages;
/**
* Static methods for the Providers page.
*/
class CatFiftyTwo
{
/**
* @Param \XF\Pub\Controller\AbstractController $controller
* @Param \XF\Mvc\Reply\AbstractReply $reply
*/
public static function getData(
\XF\Pub\Controller\AbstractController $controller,
\XF\Mvc\Reply\AbstractReply &$reply
) {
if ($reply instanceof \XF\Mvc\Reply\View) {
$catinfo = \XF::db()->fetchAll("SELECT * FROM xf_user");
$reply->setParam('catinfo', $catinfo);
}
}
}
?>
2) Now, I have created a new node from Admin
View attachment 229619
View attachment 229620
3) Than I move to public navigation in the Admin and created a new page with Visitor page name and linked it with the Front Page Node.
View attachment 229622
4) After doing all these steps I opened the front end website
View attachment 229623
there is a menu named Front Pages at the top but nothing data is displayed here.
My Aim is just to create a new page from Admin and showing the data at front from the database.
Please let me know if I have misunderstood something or made any mistake here
<?php
namespace Site\Pages;
class CatFiftyTwo
{
public static function getData(\XF\Pub\Controller\AbstractController $controller, \XF\Mvc\Reply\AbstractReply &$reply)
{
if ($reply instanceof \XF\Mvc\Reply\View)
{
$finder = \XF::finder('XF:User')->where('user_id', '<', 100);
$finder->order('username', 'ASC');
$reply->setParam('catinfo', $finder->fetch());
}
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.