Posted in site documentation
432
3:57 am, June 14, 2021
 

Comments Listing should be a custom list rather than using search

<p>For some reason when i listed the comments under posts on this site, i used the search function and then searched for the related uid, which maybe was easier at the time than adding an additional category to search.</p>
<p>When I did this it also recorded the uid in the search results which is annoying.&nbsp;</p>
<p>Now i need to change the list order on the comments and i cant as it will effect search so i need to redo it now anyway. So i should have just added an additional list type in the first place.</p>
<p>Current Search Code</p>
<h4>PHP</h4>
<pre><code class="php hljs">if($commentsviewenabled) {<br /> &nbsp; / rather than doing a search here it should be doing a comment list /<br />&nbsp; &nbsp; $commentslist = $comments-&gt;listall(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $start = 0,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $max = 200,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $listtype = "search",<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $templatefile = "relateddiscussions-full-list-item.html",<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $searchterm = $class-&gt;uid<br />&nbsp; &nbsp; &nbsp; &nbsp; );<br />&nbsp; &nbsp; &nbsp; &nbsp; //$template-&gt;set("relateddiscussions",$relateddiscussions);<br />&nbsp; &nbsp; &nbsp; &nbsp; $pagecontent .= $commentslist;<br />}</code></pre>
<p>Added a custom list, not sure why i didnt just do this, as its quite easy.&nbsp;</p>
<h4>PHP</h4>
<pre><code class="php hljs">if($listtype == "comments") {<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql = "select * from $dbtablename where linkeduid = '$searchterm' order by insdate asc limit $start,$max";<br />} </code></pre>
<p>then just changed the listing type to comments rather than search</p>
<h4>PHP</h4>
<pre><code class="php hljs">if($comments
viewenabled) {<br /> &nbsp; $commentslist = $comments-&gt;listall(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $start = 0,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $max = 200,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $listtype = "comments",<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $templatefile = "relateddiscussions-full-list-item.html",<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $searchterm = $class-&gt;uid<br />&nbsp; &nbsp; &nbsp; &nbsp; );<br /> &nbsp; &nbsp; &nbsp; $pagecontent .= $comments_list;<br />}</code></pre>

View Statistics
This Week
232
This Month
1010
This Year
529

No Items Found.

Add Comment
Type in a Nick Name here
 
Related Search Terms
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
You drown not by falling in the river, but by staying submerged.
Unknown
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.