forums.eqdkp.com: How to make a new page use Itemstats - forums.eqdkp.com

Jump to content

  • (3 Pages) +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

How to make a new page use Itemstats Rate Topic: ***** 1 Votes

#1 Guest_Greenoaf_*

  • Group: Guests

Posted 20 February 2006 - 05:56 AM

This is a question that could fit into several categories, but I think John can help me, so I'm posting here :)

Ok, I have created a "rules" page to add the details of how to bid and rules behind the way we do things.

I want this page to be completely seperate from the News, because I would still like to add new News and let that continue to stack up without touching the Rules.

Howto: Add a non-Eqdkp page
The above link lists how to add all the PHP scripting to an HTML page. You enter all the HTML you want to display and it will ensure you still have the look and feel of your eqdkp.

I have discovered that in doing this, you lose the itemstats function because everything is listed in the HTML and not entered via the database.

I have created:
rules.php
rules.html

In the MySQL database, I created: (my prefix is CG_TKP)
CG_TKP_rules (Table)
rules_title (field - 255)
rules_text (field - text unlimited)

I would like to simply put the data into the database (PHPMyAdmin) by hand (I don't want to create any kind of form or complicatedness).

However, I do not know how to do the query in the PHP file to display it in the HTML. I know you have to setup the functions in the PHP file and call the display in the HTML, but I'm not exactly sure how.

I have entered all the data into the database to look just like a News Entry. Example:

-------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743923][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_jewelry_ring_47.gif[/img] Bloodlord Mandokir[/url][/b]

-[item]Zanzil's Seal[/item]: 1.5 tkp
-[item]Animist's Leggings[/item]: 2.5 tkp
-[item]Hakkari Loa Cloak[/item]: 2 tkp
-[item]Bloodtinged Kilt[/item]: 2.5 tkp
-[item]Overlord's Crimson Band[/item]: 1.5 tkp
-[item]Blooddrenched Grips[/item]: 2.5 tkp
-[item]Bloodsoaked Pauldrons[/item]: 2.5 tkp
-[item]Primalist's Seal[/item]: 1.5 tkp
-[item]Halberd of Smiting[/item]: 5 tkp
-[item]Bloodlord's Defender[/item]: 5 tkp
-[item]Mandokir's Sting[/item]: 5 tkp
-[item]Warblade of the Hakkari[/item]: 5 tkp

 -------------------------------------------------------------------


Basically, I want whats in the News page of CG TKP to go into the Rules page so I can use the News page as normal.

Can anyone help me out with this?
Greenoaf

#2 Guest_John_*

  • Group: Guests

Posted 20 February 2006 - 09:04 AM

So let me get this straight...

You want to put those flat rate items on your rules page instead of the news page?

---

If so...that's cake!

#3 User is offline   psyker7

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 519
  • Joined: 07-October 05
  • Location:Victoria, Australia

Posted 20 February 2006 - 01:56 PM

Edited so the full instructions are near front of this post:

Be warned that this is a total hack and isn't easy to read ;)

http://anzacsguild.c...tpoints.php.txt
http://anzacsguild.c...points.html.txt

setpoints.php belongs in the eqdkp root directory
setpoints.html belongs in the eqdkp/templates/default directory

To change point values etc, edit setpoints.php

The bit in between lines
$message = '<table width="100%" border="0" cellspacing="1" cellpadding="2">

after the ' down to the line
';


is simply an html document, copy it into a blank document to see what it will look like, do the editing then copy it back in between the quotes in the php document.
What the php does is run this html document through the itemstats parser so that everytime it comes across the [item][/item] tags it converts it to a mouseover link.

Make sure you add a "\" before every ' inside the message text.
For example:

Onyxia's Lair
becomes
Onyxia\'s Lair

Otherwise the php read closing the $message variable too early and returns an error message.

For those trying to get the [itemicon] [/itemicon] tags to work, I added a custom function to phpbb_itemstats.php

basically:

~~~~~~~~~
Open itemstats/phpbb_itemstats.php
~~~~~~~~~
AFTER
~~~~~~~~~
// Finally, replace the bbcode with the html.

		$message = str_replace($match[0], $item_html, $message);

	}

~~~~~~~~~
INSERT
~~~~~~~~~
while (preg_match('#\[itemicon\](.+?)\[/itemicon\]#s', $message, $match))

	{

		// Grab the item name.

		$item_name = $match[1];



		// Get the proper name of this item.

		$item_name = $item_stats->getItemName($item_name, true);

		//Initialize the icon

		$item_icon =  $item_name;

		

		// Add the icon to the name.
		$item_icon_link = $item_stats->getItemIconLink($item_name);
		if (!empty($item_icon_link))
		{
			$item_icon = "<img class='smallitemicon' src='" . $item_icon_link . "'> ";
		}

		// Get the tooltip html for this item and apply it to the html.

		$item_tooltip_html = $item_stats->getItemTooltipHtml($item_name);

		if (!empty($item_tooltip_html))

		{

			$item_icon = "<span " . $item_tooltip_html . ">" . $item_icon . "</span>";

		}



		// If this item has a link to the info site, add this link to the HTML.  If it doesn't have a link, it

		// means the item hasn't been found yet, so put up a link to the update page instead.

		$item_link = $item_stats->getItemLink($item_name);

		if (!empty($item_link))

		{

			$item_icon = "<a class='forumitemlink' target='_blank' href='" . $item_link . "'>" . $item_icon . "</a>";

		}

		else

		{

			$item_link = 'itemstats/updateitem.php?item=' . urlencode(urlencode($item_name));

			$item_icon = "<a class='forumitemlink' href='$item_link'>" . $item_icon . "</a>";

		}


		// Finally, replace the bbcode with the html.

		$message = str_replace($match[0], $item_icon, $message);

	}


Hope it helps :)


If you are having troubles, you may be using a different version of itemstats.
http://forums.eqdkp....?showtopic=3331 is the version installed on my website.
Use the "common errors" thread below that if you have trouble installing.

Also

View PostAnnoar, on Mar 1 2006, 04:22 AM, said:

for anyone who uses this there is an additional piece of info u need. everythign in the <newpage>.php that you want displated on screen is contained within apostrophes.. 'like this'. but many items names contain apostrophes such as [Mar'li's Touch], and each time the code sees an apostrophe it thinks its the stop/start of the main pair. After pulling a fair amount of my hair out i found the solution on on Anzacs setpoints.php Wherever an apostrophe is preceded by a \ its simply printed to screen and not mistaken for code. Simply write it as [item]Mar\'li\'s Touch[/item].

Hope that saves people some time/stress :rolleyes:


#4 Guest_Greenoaf_*

  • Group: Guests

Posted 20 February 2006 - 06:47 PM

Ok,

I simply want to put the code entry above into the database and create a page to pull it from the database and display it. I just don't know how to do the query........

<!-- INCLUDE page_header.html -->


  <!-- BEGIN itemrow -->


	  {itemrow.MESSAGE}


  <!-- END itemrow -->
<!-- INCLUDE page_tail.html -->


I understand how you did this, you put everthing into HTML and pushed it into MESSAGE in the PHP and then displayed it out in the HTML......

Not what I was looking for....

Ok, if you look into the EQDKP_news(table) you find news_headline(row) and news_message(row), all I want to do is create one instance of that, I already put it in EQDKP_rules(table) to be found in rules_title(row) and rules_text(row)

I want to pull this information into the rules page to display, I just don't know how to setup the query and output in the HTML

I have put this into the rules_text and I want it to come out looking just like the news without having to pre-format anything

[b]Point Values for Items in ZG[/b]

*This page is going to get moved to a new "Item Values" page soon, this will be used strictly for News*

-------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743923][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_jewelry_ring_47.gif[/img] Bloodlord Mandokir[/url][/b]

-[item]Zanzil's Seal[/item]: 1.5 tkp
-[item]Animist's Leggings[/item]: 2.5 tkp
-[item]Hakkari Loa Cloak[/item]: 2 tkp
-[item]Bloodtinged Kilt[/item]: 2.5 tkp
-[item]Overlord's Crimson Band[/item]: 1.5 tkp
-[item]Blooddrenched Grips[/item]: 2.5 tkp
-[item]Bloodsoaked Pauldrons[/item]: 2.5 tkp
-[item]Primalist's Seal[/item]: 1.5 tkp
-[item]Halberd of Smiting[/item]: 5 tkp
-[item]Bloodlord's Defender[/item]: 5 tkp
-[item]Mandokir's Sting[/item]: 5 tkp
-[item]Warblade of the Hakkari[/item]: 5 tkp

 -------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743514][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_bracers_18.gif[/img] High Priestess Jeklik[/url][/b]

-[item]Jeklik's Opaline Talisman[/item]: 1.5 tkp
-[item]Primalist's Band[/item]: 1.5 tkp
-[item]Zulian Defender[/item]: 2.5 tkp
-[item]Seafury Boots[/item]: 2.5 tkp
-[item]Animist's Spaulders[/item]: 2.5 tkp
-[item]Jeklik's Crusher[/item]: 5 tkp

 -------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743780][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_jewelry_ring_46.gif[/img] High Priest Venoxis[/url][/b]

-[item]Zulian Stone Axe[/item]: 2.5 tkp
-[item]Zanzil's Band[/item]: 1.5 tkp
-[item]Blooddrenched Footpads[/item]: 2.5 tkp
-[item]Zulian Tigerhide Cloak[/item]: 2 tkp
-[item]Runed Bloodstained Hauberk[/item]: 4 tkp
-[item]Fang of Venoxis[/item]: 5 tkp

 -------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743805][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_zulgurubtrinket.gif[/img] High Priestess Mar'li[/url][/b]

-[item]Bloodstained Greaves[/item]: 2.5 tkp
-[item]Mar'li's Eye[/item]: 1.5 tkp
-[item]Band of Jin[/item]: 1.5 tkp
-[item]Talisman of Protection[/item]: 1.5 tkp
-[item]Flowing Ritual Robes[/item]: 4 tkp
-[item]Mar'li's Touch[/item]: 5 tkp

 -------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743948][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_jewelry_ring_44.gif[/img] High Priest Thekal[/url][/b]

-[item]Ritualistic Legguards[/item]: 2.5 tkp
-[item]Zulian Slicer[/item]: 2.5 tkp
-[item]Seal of Jin[/item]: 1.5 tkp
-[item]Seafury Leggings[/item]: 2.5 tkp
-[item]Betrayer's Boots[/item]: 4 tkp
-[item]Thekal's Grasp[/item]: 5 tkp

 -------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743951][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_banner_01.gif[/img] Jin’do The Hexxer[/url][/b]

-[item]Bloodstained Legplates[/item]: 2.5 tkp
-[item]Bloodtinged Gloves[/item]: 2.5 tkp
-[item]Bloodstained Coif[/item]: 2.5 tkp
-[item]Animist's Boots[/item]: 2.5 tkp
-[item]Blooddrenched Leggings[/item]: 2.5 tkp
-[item]Bloodsoaked Gauntlets[/item]: 2.5 tkp
-[item]The Hexxer's Cover[/item]: 2.5 tkp
-[item]Overlord's Embrace[/item]: 2 tkp
-[item]Jin'do's Evil Eye[/item]: 3.5 tkp
-[item]Jin'do's Hexxer[/item]: 5 tkp
-[item]Jin'do's Judgement[/item]: 5 tkp
-[item]Jin'do's Bag of Whammies[/item]: 5 tkp

 -------------------------------------------------------------------

[b][url=http://thottbot.com/?n=743454][img]http://s104658971.onlinehome.us/CG-WOW/Images/20x20/inv_misc_gem_bloodstone_02.gif[/img] Hakkar[/url][/b]

-[item]Cloak of Consumption[/item]: 3.5 tkp
-[item]Aegis of the Blood God[/item]: 5 tkp
-[item]The Eye of Hakkar[/item]: 3.5 tkp
-[item]Soul Corrupter's Necklace[/item]: 3.5 tkp
-[item]Gurubashi Dwarf Destroyer[/item]: 5 tkp
-[item]Bloodcaller[/item]: 5 tkp
-[item]Zin'rokh, Destroyer of Worlds[/item]: 5 tkp
-[item]Ancient Hakkari Manslayer[/item]: 5 tkp
-[item]Fang of the Faceless[/item]: 5 tkp
-[item]Warblade of the Hakkari[/item]: 5 tkp
-[item]Touch of Chaos[/item]: 5 tkp
-[item]Seafury Gauntlets[/item]: 4 tkp
-[item]Heart of Hakkar[/item]: 4 tkp

-------------------------------------------------------------------

Pharoah, Sabrice and Ruok, will be deciding how much each run is worth, and that will be posted shortly... Thanks

Edited by Greenie cause Murts a NEWB!!!


See, it is already pre-built, I just want to go get it with a query in the PHP and put the output in the rules.html

Greenoaf

#5 User is offline   psyker7

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 519
  • Joined: 07-October 05
  • Location:Victoria, Australia

Posted 20 February 2006 - 07:12 PM

so you need the php to pull that from the database?

Take a look at viewnews.php....

didnt test it but something like this:

<?php
/******************************
 * EQdkp
 * Copyright 2002-2003
 * Licensed under the GNU GPL.  See COPYING for full terms.
 * ------------------
 * viewnews.php
 * Began: Sat April 5 2003
 * 
 * $Id: rules.php,v 1.3 2003/08/16 21:09:08 tsigo Exp $
 * 
 ******************************/
 
define('EQDKP_INC', true);
$eqdkp_root_path = './';
include_once($eqdkp_root_path . 'common.php');
include_once($eqdkp_root_path . 'itemstats/eqdkp_itemstats.php');



$sql = 'SELECT rules_title rules_text
		FROM CG_TKP_rules';
$result = $db->query($sql);

if ( $db->num_rows($result) == 0 )
{
	message_die($user->lang['no_rules']);
}

$cur_hash = hash_filename("rules.php");
// print"HASH::$cur_hash::<br>";

while ( $rules = $db->fetch_record($result) )
{
	
	$message = $rules['rules_text'];
	$message = nl2br($message);
	news_parse($message);
	$message = preg_replace('#(\&amp;){2,}#', '&amp;', $message);
	$message = itemstats_parse($message);
	
	$tpl->assign_block_vars('rules_row', array(
		'ROW_CLASS' => $eqdkp->switch_row_class(),
		'HEADLINE' => stripslashes($['rules_title']),
		'MESSAGE' => $message)
	);
}
$db->free_result($result);



$eqdkp->set_vars(array(
	'page_title'	=> sprintf($user->lang['title_prefix'], $eqdkp->config['guildtag'], $eqdkp->config['dkp_name']),
	'template_file' => 'rules.html',
	'display'	   => true)
);
?>


should work if you edit rules.html properly.

#6 Guest_Greenoaf_*

  • Group: Guests

Posted 21 February 2006 - 09:23 AM

Well... I guess I couldn't.....

I want it to be as simple as:

<!-- INCLUDE page_header.html -->
<!-- INCLUDE sidemenu.html -->
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<th>
	{HEADLINE}
</th>
</tr>
<tr>
<td>
	{MESSAGE}
</td>
</tr>
</table>

<!-- INCLUDE page_tail.html -->


But I guess it isn't :)

#7 User is offline   psyker7

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 519
  • Joined: 07-October 05
  • Location:Victoria, Australia

Posted 21 February 2006 - 01:02 PM

try

<!-- INCLUDE page_header.html -->
<!-- INCLUDE sidemenu.html -->
<table width="100%" border="0" cellspacing="1" cellpadding="2">
  <!-- BEGIN rules_row -->
  <tr>
	<td>
	  <b style="font-size:13px">{rules_row.HEADLINE}</b> <br /><br />
	  {rules_row.MESSAGE}
	</td>
  </tr>
  <!-- END rules_row -->
  <tr>
	<th class="footer">&nbsp;</th>
  </tr>
</table>
<!-- INCLUDE page_tail.html -->


#8 Guest_Greenoaf_*

  • Group: Guests

Posted 21 February 2006 - 04:11 PM

Thank you so much for your help so far!! you guys are the greatest!!!

But....

Parse error: parse error, unexpected '[', expecting T_VARIABLE or '$' in /homepages/25/d115395929/htdocs/CG-WOW/CG-TKP/rules.php on line 44


Greenoaf

#9 User is offline   psyker7

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 519
  • Joined: 07-October 05
  • Location:Victoria, Australia

Posted 21 February 2006 - 07:57 PM

As i said i didn't test it....

line 44 is
'HEADLINE' => stripslashes($['rules_title']),



my bad...

should be

'HEADLINE' => stripslashes($rules['rules_title']),

#10 Guest_Greenoaf_*

  • Group: Guests

Posted 21 February 2006 - 11:19 PM

You guys are so much help!!!

The page did not error, however.... the MESSAGE didn't come out.....

http://tkp.cgguild.org/rules.php

The HEADLINE comes out fine, but the MESSAGE doesn't show... and yes, it is in the database....

Greenoaf

#11 User is offline   psyker7

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 519
  • Joined: 07-October 05
  • Location:Victoria, Australia

Posted 22 February 2006 - 04:59 AM

can't be sure without actually doing it all and i'm a bit lazy to set up a database just for this :P
From what I figure it should be working...

Wouldn't simply having a static page be easier anyway??

#12 Guest_Greenoaf_*

  • Group: Guests

Posted 22 February 2006 - 01:38 PM

It is a static page..... but the information is coming from the database....

The problem is that I want to do this with about 4 other pages... so if I can get it down with this one, then I can just use the same formatting for the others......

#13 User is offline   psyker7

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 519
  • Joined: 07-October 05
  • Location:Victoria, Australia

Posted 22 February 2006 - 02:12 PM

Few small things.

{
	message_die($user->lang['no_rules']);
}


Replace with
{
	message_die($user->lang['no_news']);
}


Try adding a ";" after
while ( $rules = $db->fetch_record($result) )
{
	
	$message = $rules['rules_text'];
	$message = nl2br($message);
	news_parse($message);
	$message = preg_replace('#(\&amp;){2,}#', '&amp;', $message);
	$message = itemstats_parse($message);
	
	$tpl->assign_block_vars('rules_row', array(
		'ROW_CLASS' => $eqdkp->switch_row_class(),
		'HEADLINE' => stripslashes($['rules_title']),
		'MESSAGE' => $message)
	);
}


What my page was doing but is exactly the same as what you are wanting, minus the fiddling with databases.... /shrug

#14 Guest_Greenoaf_*

  • Group: Guests

Posted 22 February 2006 - 02:46 PM

You guys have been the greatest, but I am going to take your advise and just do the original idea of a static page.....

It took me like 3 min's to build it and it seems like a much easier setup....

I have already got it up and running

Item Costs

Thank you so much again!!!!
(I will be donating)
Greenoaf

#15 Guest_Annoar_*

  • Group: Guests

Posted 28 February 2006 - 09:22 AM

View Postpsyker7, on Feb 20 2006, 09:56 PM, said:

Take a look at http://www.anzacsgui...p/setpoints.php :)

Then find the code for it at
http://www.anzacsgui...tpoints.php.txt
and
http://www.anzacsgui...points.html.txt

Hope you can figure that out... :)


this is absolutely sweet and exactly what i needed. for anyone who uses this there is an additional piece of info u need. everythign in the <newpage>.php that you want displated on screen is contained within apostrophes.. 'like this'. but many items names contain apostrophes such as [Mar'li's Touch], and each time the code sees an apostrophe it thinks its the stop/start of the main pair. After pulling a fair amount of my hair out i found the solution on on Anzacs setpoints.php Wherever an apostrophe is preceded by a \ its simply printed to screen and not mistaken for code. Simply write it as [item]Mar\'li\'s Touch[/item].

Hope that saves people some time/stress :rolleyes:

  • (3 Pages) +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users