DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • May 19, 2013, 04:49:39 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1] 2 3   Go Down
  Print  
Author Topic: Altering page layout - order and content of charstats  (Read 1226 times)
0 Members and 1 Guest are viewing this topic.
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« on: March 05, 2012, 02:33:55 PM »

I'm looking to move charstats around and re-order some of the info within them on 3 specific skins only. Is it possible? if so, how?

Thanks in advance,
~Rayn
« Last Edit: March 05, 2012, 05:14:17 PM by RaynDarren » Logged

Visit me at my new home!
Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #1 on: March 05, 2012, 04:41:10 PM »

If you want to change where the charstats appear in the skin, that is easy enough -- just modify the corresponding template file and move the {stats} entry where you want them to appear.

The re-ordering is more difficult.  The order of charstats is moderately hardcoded in lib/pageparts.php.  A core edit may be easier, but there is a way out that allows this to be done in a module.  Set a very low priority hook on "charstats", and then modify the global $charstats_info array to reflect the order you want.  This might be most easily done by getting a copy of it, wiping the charstats, and then re-adding them all (taking care to add the ones whose order you care about first).

As for detecting the template itself, by the time this code is called then prepare_template() should already have been called by page_header().  That means that the template name will be in $session['templatename'].


EDIT: Fixed a couple of typos.
EDIT: Put the lib/ in to make it clear where pageparts.php lives.
« Last Edit: March 08, 2012, 07:29:16 AM by Boris735 » Logged
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #2 on: March 05, 2012, 05:51:32 PM »

Awesomeness! Thanks so much Borris!


::EDIT::

The site I'm doing these skins for has an odd set up for the ftp.. infact, it's accessed through the cpannel. I cannot find the pageparts in the root directory. The only instance of it is in the lib folder. Any idea why?
« Last Edit: March 07, 2012, 06:05:06 PM by RaynDarren » Logged

Visit me at my new home!
Afkamm
Mod God
*****
Offline Offline

Posts: 1563

MarcTheSlayer


View Profile WWW
« Reply #3 on: March 08, 2012, 05:20:05 AM »

Because that's where it lives. :-)
Logged

Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #4 on: March 08, 2012, 07:30:19 AM »

Apologies for not making that clearer; I've adjusted the earlier post to prevent confusion from anyone who sees this later.  The file in question is, indeed, lib/pageparts.php.
Logged
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #5 on: March 08, 2012, 02:22:56 PM »

Well, don't I feel silly now, thanks!
Logged

Visit me at my new home!
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #6 on: April 09, 2012, 02:45:08 PM »

Apologies for bringing up an old thread. Boris's suggestion of altering lib/pageparts.php did not work. Unless I did it wrong that is. This is what I did:

Original code:
addcharstat("Vital Info");
      addcharstat("Name", $u['name']);
      addcharstat("Level", "`b".$u['level'].check_temp_stat("level",1)."`b");
      if ($u['alive']) {
         addcharstat("Hitpoints", $u['hitpoints'].check_temp_stat("hitpoints",1).
                           "`0/".$u['maxhitpoints'].check_temp_stat("maxhitpoints",1));
         addcharstat("Turns", $u['turns'].check_temp_stat("turns",1));
         addcharstat("Attack", $atk.check_temp_stat("attack",1));
         addcharstat("Defense", $def.check_temp_stat("defense",1));
      } else {
         $maxsoul = $u['level'] * 5 + 50;
         addcharstat("Soulpoints", $u['soulpoints'].check_temp_stat("soulpoints",1)."`0/".$maxsoul);
         addcharstat("Torments", $u['gravefights'].check_temp_stat("gravefights",1));
         addcharstat("Psyche", 10+round(($u['level']-1)*1.5));
         addcharstat("Spirit", 10+round(($u['level']-1)*1.5));
      }
      addcharstat("Spirits", translate_inline("`b".$spirits[(int)$u['spirits']]."`b"));
      if ($u['race'] != RACE_UNKNOWN) {
         addcharstat("Race", translate_inline($u['race'],"race"));
      }else {
         addcharstat("Race", translate_inline(RACE_UNKNOWN,"race"));
      }

Modified code:
addcharstat("Vital Info");
         addcharstat("Attack", $atk.check_temp_stat("attack",1));
         addcharstat("Defense", $def.check_temp_stat("defense",1));
      if ($u['alive']) {
         addcharstat("Hitpoints", $u['hitpoints'].check_temp_stat("hitpoints",1).
                           "`0/".$u['maxhitpoints'].check_temp_stat("maxhitpoints",1));
         addcharstat("Turns", $u['turns'].check_temp_stat("turns",1));
      } else {
         $maxsoul = $u['level'] * 5 + 50;
         addcharstat("Soulpoints", $u['soulpoints'].check_temp_stat("soulpoints",1)."`0/".$maxsoul);
         addcharstat("Torments", $u['gravefights'].check_temp_stat("gravefights",1));
         addcharstat("Psyche", 10+round(($u['level']-1)*1.5));
         addcharstat("Spirit", 10+round(($u['level']-1)*1.5));
      }
      addcharstat("Name", $u['name']);
      addcharstat("Level", "`b".$u['level'].check_temp_stat("level",1)."`b");
      addcharstat("Spirits", translate_inline("`b".$spirits[(int)$u['spirits']]."`b"));
      if ($u['race'] != RACE_UNKNOWN) {
         addcharstat("Race", translate_inline($u['race'],"race"));
      }else {
         addcharstat("Race", translate_inline(RACE_UNKNOWN,"race"));
      }

The lines did not move, the template did not change. Help?

URL for viewing: http://www.dragonsofmyth.com/test/home.php?

Thanks,
~Rayn
Logged

Visit me at my new home!
Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #7 on: April 09, 2012, 05:41:57 PM »

Do you have a module installed that already hooks into the charstats and reorganises them?  That seems to be the only way that your changes could be ignored like this.  The other option, of course, is that the modified file has not ended up in the right place; a possible check for that would be to add a completely new charstat and see if it shows up or not.
Logged
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #8 on: April 09, 2012, 06:53:01 PM »

Fixed! Had it in the wrong place. ~blush~.

Now, this alters all templates, is there a way to alter only selected ones?
Logged

Visit me at my new home!
Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #9 on: April 10, 2012, 12:00:49 AM »

You'd have to push template-specific layout logic into code somewhere, whether you do that in lib/pageparts.php or a module.
Logged
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #10 on: April 10, 2012, 12:03:05 AM »

I haven't the faintest idea how to do that. I'm assuming it isn't as simple as pulling a pref from somewhere?
Logged

Visit me at my new home!
ArthuruhtrA
Mod God
*****
Offline Offline

Posts: 553


chown -R us ./base


View Profile WWW
« Reply #11 on: April 10, 2012, 09:04:45 AM »

No, you have to write code on a low-priority hook to charstats that changes the order of the $charstats_info array within a conditional operating on the value of $session['templatename'] as previously stated by Boris.
Logged

Dragons of MythMy Modules | Tynastera!
BOWTIES ARE COOL
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #12 on: April 10, 2012, 11:22:09 AM »

So a priority of 10 would be low enough?

Would this work:

$session ['grass'], || ['gold'], || ['darkforest']
Logged

Visit me at my new home!
ArthuruhtrA
Mod God
*****
Offline Offline

Posts: 553


chown -R us ./base


View Profile WWW
« Reply #13 on: April 10, 2012, 12:52:58 PM »

I don't know what would be low enough. I might go a little lower just to be safe, but I doubt anything else is under 10... so 9 is probably safe.
As for that code, I'm not sure what it's supposed to do. Whatever it is, it won't do it.
Logged

Dragons of MythMy Modules | Tynastera!
BOWTIES ARE COOL
RaynDarren
Mod God
*****
Offline Offline

Posts: 638


View Profile WWW
« Reply #14 on: April 10, 2012, 12:57:11 PM »

Alrighty, will try 9 then Smiley

Those are the three templates that would have the alterd charstats. I misunderstood, I thought 'templatename' was replaced with the name of the template. Since they are the same layout for charastats for those three, I'd hoped they could be called all at once.
Logged

Visit me at my new home!
Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
24 Guests, 2 Users
Aeo , Astarael|Jack
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search