vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Getting the latest Article to display (https://vborg.vbsupport.ru/showthread.php?t=323583)

Necrophyte 10-05-2016 06:19 PM

Getting the latest Article to display
 
So I'm trying to use one of the modules on my home page to list the latest article that has the tag 'spotlight' in it. Will only display the latest one, not all of them. I've no idea where to even start. I haven't figured out how to edit modules themselves yet, but I imagine I can find what I'm looking for in the 'Slider' Module.
Any hints on where or how would be awesome.

You can almost do this with the Search Module.
Using JSON:
{"tag":["spotlight"],"channel":["13"],"sort":{"created":"desc"},"view":null,"exclude_ty pe":["vBForum_PrivateMessage"]}

Can't figure out what possible views other than compact, and topic. If there was a full, or post (Yes I tried those) and it showed the full article. That would have been awesome so there has to be another way.

noypiscripter 10-05-2016 07:29 PM

You can use PHP module and do a search with that JSON criteria. You can style it the way you want to.

Necrophyte 10-05-2016 08:55 PM

Glenn,

Thanks for the quick response as always. I'm lost on how I can get it to search and display the data in a PHP though. I can get the search function to find it properly, but I can't get it to display just the entire article without the click more.

Lynne 10-06-2016 12:29 AM

So you are saying your aren't familiar with how to write PHP/MySQL code to do this or that you don't know the exact query because you are unfamiliar with the database schema?

Necrophyte 10-06-2016 01:49 AM

I could run the queries to show but then I have BB code through out. Is there a way to parse this to HTML?

noypiscripter 10-06-2016 02:32 AM

There's a parse function called parseNodeText in the bbcode frontend controller that you can call.

Necrophyte 10-06-2016 03:35 AM

TY, that's what I needed to know!

--------------- Added [DATE]1475776484[/DATE] at [TIME]1475776484[/TIME] ---------------

For anyone that comes to this page looking for answers. You can open a PHP Module.
I wanted mine to be displayed in a max height of 800px. You can change that to what you want or remove it.
In the Query if you do not wish to have a taglist search. Just remove : 'AND taglist LIKE '%spotlight%''

You'll also need to know the nodeid for articles. Mine is 13. Change 13 to whatever your article nodeid is. You can find them in the channel manager.

Put the following code:
Code:

        global $vbulletin;
        echo "<div style='height: 800px; max-height: 800px; overflow: auto;'>";
        $result = $vbulletin->db->query("SELECT nodeid FROM " . TABLE_PREFIX . "node WHERE parentid = 13 AND taglist LIKE '%spotlight%' ORDER BY created DESC LIMIT 1");
        if ($row = $result->fetch_assoc()){
                echo vB5_Frontend_Controller_Bbcode::parseNodeText($row['nodeid']);
        }else{
                echo "<div style='text-align: center; padding: 10px;'><h2>Could not find any articles using tag 'spotlight'</h2></div>";
        }
        unset($row);
        unset($result);
        echo "</div>";


noypiscripter 10-06-2016 09:05 PM

You will also need to add the table prefix (if any). This is not required if the TABLE_PREFIX global variable is added in the query.

Code:

"SELECT nodeid FROM " . TABLE_PREFIX . "node ....";
There was also a typo in your CSS. Should be:

Code:

max-height: 800px;
instead of:

Code:

max-height= 800px;
Use colon instead of equal sign.

Necrophyte 11-13-2016 02:43 PM

You are correct sir. I edited the post to use your changes.


All times are GMT. The time now is 03:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01008 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete