5 Replies - 234 Views - Last Post: 17 February 2015 - 03:25 PM Rate Topic: -----

#1 NonePHP  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-February 15

[MyBB] Plugin, how cache read?

Posted 14 February 2015 - 04:35 PM

Hello!

How to read from the cache prefix from the last topic on the main page? Do you have to have some database query?

Now I like:
<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.");
}


function prefix_index_info()
{
    return array (
        "name"          => "Prefix Thread On Index",
        "description"   => "",
        "website"       => "",
        "author"        => "Jose",
        "authorsite"    => "",
        "version"       => "0.1",
        "guid"          => "",
        "compatibility" => "*"
    );
}

function prefix_index_activate()
{

}

function prefix_index_deactivate()
{

}

$plugins->add_hook('build_forumbits_forum', 'prefix_index');
function prefix_index(&$forum)
{
	global $cache, $thread, $templates, $prefix;

	require_once MYBB_ROOT."inc/functions_forumlist.php";

	$prefix_index = $cache->read('threadprefixes');
	$prefix = '';

	if($thread['prefix'] && !empty($prefix_index[$thread['prefix']]))
	{
		$prefiks = $prefix_index[$thread['prefix']];
		$prefiks['prefix'] = htmlspecialchars_uni($prefiks['prefix']);
		$prefiks['displayname'] = htmlspecialchars_uni($prefiks['displayname']);
		$prefiks['forums'] = 2;
		eval('$prefix = "'.$templates->get('forumbit_depth2_forum_lastpost').'";');
	}


} 
?>

But unfortunately, nothing is displayed.
Does anyone have any suggestions? I cordially greet! smile

I do not want to edit the file! http://community.myb...read-77229.html

Is This A Good Question/Topic? 0
  • +

Replies To: [MyBB] Plugin, how cache read?

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 834
  • View blog
  • Posts: 3,047
  • Joined: 15-January 14

Re: [MyBB] Plugin, how cache read?

Posted 16 February 2015 - 09:37 AM

What is the purpose of the prefix_index function? Is it just supposed to set the $prefix variable? Is it the if statement in that function which is not doing what you expect?
Was This Post Helpful? 1
  • +
  • -

#3 NonePHP  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-February 15

Re: [MyBB] Plugin, how cache read?

Posted 16 February 2015 - 03:49 PM

The purpose of the "prefix index" is the prefix to display the last post on the main page. Unfortunately, it does not provide the results of the Items. Thank you for your interest in this topic.
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 834
  • View blog
  • Posts: 3,047
  • Joined: 15-January 14

Re: [MyBB] Plugin, how cache read?

Posted 16 February 2015 - 04:09 PM

The function doesn't display or return anything, if that if statement succeeds then it evals a line of code to set a global variable. You can print that line of code if you want to see what it's running.
Was This Post Helpful? 1
  • +
  • -

#5 NonePHP  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-February 15

Re: [MyBB] Plugin, how cache read?

Posted 17 February 2015 - 03:03 PM

So what exactly should I do in this situation? Thank you in advance for your valuable advice!
Was This Post Helpful? 0
  • +
  • -

#6 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 834
  • View blog
  • Posts: 3,047
  • Joined: 15-January 14

Re: [MyBB] Plugin, how cache read?

Posted 17 February 2015 - 03:25 PM

It's hard for me to say without knowing the architecture of that forum software, I don't know how it works. It looks like that function is set to run as part of an event dispatching system (the add_hook line), but I don't know what the function is expected to do when that hook gets triggered.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1