Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
  #1  
Old 10-05-2016, 06:19 PM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 10-05-2016, 07:29 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use PHP module and do a search with that JSON criteria. You can style it the way you want to.
Reply With Quote
  #3  
Old 10-05-2016, 08:55 PM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 10-06-2016, 12:29 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 10-06-2016, 01:49 AM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I could run the queries to show but then I have BB code through out. Is there a way to parse this to HTML?
Reply With Quote
  #6  
Old 10-06-2016, 02:32 AM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There's a parse function called parseNodeText in the bbcode frontend controller that you can call.
Reply With Quote
Благодарность от:
Lynne
  #7  
Old 10-06-2016, 03:35 AM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>";
Reply With Quote
2 благодарности(ей) от:
delicjous, Lynne
  #8  
Old 10-06-2016, 09:05 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Благодарность от:
Lynne
  #9  
Old 11-13-2016, 02:43 PM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:05 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07859 seconds
  • Memory Usage 2,244KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (4)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete