Jump to content

Recommended Posts

Posted (edited)

<?php

if (!defined('FLUX_ROOT')) exit;

$title = 'Castles';

$sql = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";

$sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";

$sth = $server->connection->getStatement($sql);

$sth->execute();

$castles = $sth->fetchAll();

$castleNames = Flux::config('CastleNames')->toArray();

?>

HOW can I put some Limits uppon showing the records of the castle owned. gusto ko kc 5 castle lang ang mag papakita every page. pano po ba? Like sa GUILD Rank 20 pano po malalagyan ng limits?

Help Plss

Edited by argelrock
Posted (edited)

Look for

$sql .= "LIMIT ".(int)Flux::config('LimitCastle');

Change to

$sql .= "LIMIT 5";

EDIT:

Yung guild ranking limit kasi nasa config/application.php so I think nandun din ung castle limit.

kapag nandun ung LimitCastle na variable un na lang palitan mo para di mo na palitan tong line na to $sql .= "LIMIT ".(int)Flux::config('LimitCastle');

Edited by jupeto
Posted

Look for

$sql .= "LIMIT ".(int)Flux::config('LimitCastle');

Change to

$sql .= "LIMIT 5";

EDIT:

Yung guild ranking limit kasi nasa config/application.php so I think nandun din ung castle limit.

kapag nandun ung LimitCastle na variable un na lang palitan mo para di mo na palitan tong line na to $sql .= "LIMIT ".(int)Flux::config('LimitCastle');

SIr sorry mali po post ko

eto po pala ung Code

<?php

if (!defined('FLUX_ROOT')) exit;

$title = 'Castles';

$sql = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";

$sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";

$sth = $server->connection->getStatement($sql);

$sth->execute();

$castles = $sth->fetchAll();

$castleNames = Flux::config('CastleNames')->toArray();

?>

gusto ko sana lagyan ng Limit kaso pag sinubukan ko po ung -- $sql .= "LIMIT ".(int)Flux::config('LimitCastle'); at ung $sql .= "LIMIT 5"; hindi na po nag a apear ung mga records

Posted

I see, in this case, kelangan mong itweak yung themes/your_theme_name/castle/index.php...

ewan lang kung meron na jang existing code for that per ginagawan ko na ng script yun... di ka naman siguro nagmamadali hehe

Posted

I see, in this case, kelangan mong itweak yung themes/your_theme_name/castle/index.php...

ewan lang kung meron na jang existing code for that per ginagawan ko na ng script yun... di ka naman siguro nagmamadali hehe

^^ ok lang po.. I can wait. I hope you can help me po thanks in advance ^_^
Posted (edited)

Got it working na without search function! final code below po,

in modules/castle/index.php copy below and replace your current castle index code


<?php
if (!defined('FLUX_ROOT')) exit;

$title = 'Castles';

// $sql  = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";
// $sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";

// $sth  = $server->connection->getStatement($sql);
// $sth->execute();

$sql  = "SELECT COUNT(castle_id) AS total FROM {$server->charMapDatabase}.guild_castle";

$sth  = $server->connection->getStatement($sql);

$sth->execute();
$paginator = $this->getPaginator($sth->fetch()->total,array('perPage'=>(int)Flux::config('CastleLimit')));

$sql  = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";
$sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";

$sql  = $paginator->getSQL($sql);
$sth  = $server->connection->getStatement($sql);

$sth->execute();

$castles = $sth->fetchAll();
$castleNames = Flux::config('CastleNames')->toArray();

?>

save and exit.

in themes/your_theme_name/castle/index.php copy below and replace your current castle index code

<?php if (!defined('FLUX_ROOT')) exit; ?>
<h2>Castles</h2>
<p>This page shows what castles are activated and which guilds own them.</p>
<?php if ($castles): ?>
<?php echo $paginator->infoText() ?>
<table class="vertical-table">
<tr>
<th>Castle ID</th>
<th>Castle</th>
<th colspan="2">Guild</th>
</tr>
<?php foreach ($castles as $castle): ?>
<tr>
<td align="right"><?php echo htmlspecialchars($castle->castle_id) ?></td>
<td>
<?php if (array_key_exists($castle->castle_id, $castleNames) && $castleNames[$castle->castle_id]): ?>
<?php echo htmlspecialchars($castleNames[$castle->castle_id]) ?>
<?php else: ?>
<span class="not-applicable">Unknown<?php echo " (".$castle->castle_id.")" ?></span>
<?php endif ?>
</td>
<?php if ($castle->guild_name): ?>
<?php if ($castle->emblem_len): ?>
<td width="24"><img src="<?php echo $this->emblem($castle->guild_id) ?>" /></td>
<td>
<?php if ($auth->actionAllowed('guild', 'view') && $auth->allowedToViewGuild): ?>
<?php echo $this->linkToGuild($castle->guild_id, $castle->guild_name) ?>
<?php else: ?>
<?php echo htmlspecialchars($castle->guild_name) ?>
<?php endif ?>
</td>
<?php else: ?>
<td colspan="2"><?php echo htmlspecialchars($castle->guild_name) ?></td>
<?php endif ?>
<?php else: ?>
<td colspan="2"><span class="not-applicable"><?php echo htmlspecialchars(Flux::message('NoneLabel')) ?></span></td>
<?php endif ?>
</tr>
<?php endforeach ?>
</table>
<?php echo $paginator->getHTML() ?>
<?php else: ?>
<p>No castles found. <a href="javascript:history.go(-1)">Go back</a>.</p>
<?php endif ?>

save and exit.

in lib/Flux/Paginator.php

find

public function infoText()
{
 $currPage = $this->currentPage;
 $results  = Flux::config('ResultsPerPage');
 $infoText = sprintf(
  Flux::message('FoundSearchResults'),
  $this->total, $this->numberOfPages, ($currPage*$results-($results - 1)), $currPage * $results < $this->total ? ($currPage*$results) : ($this->total)
 );
 return sprintf('<p class="info-text">%s</p>', $infoText);
}

change to



public function infoText()
{
$currPage = $this->currentPage;
// $results  = Flux::config('ResultsPerPage');
$results  = $this->perPage;
$infoText = sprintf(
Flux::message('FoundSearchResults'),
$this->total,
$this->numberOfPages,
($currPage*$results-($results - 1)),
$currPage * $results < $this->total ? ($currPage*$results) : ($this->total)
);
return sprintf('<p class="info-text">%s</p>', $infoText);
}

save and exit.

in config/application.php

find

'CharRankingLimit'	=> 10,						//

add above

'CastleLimit'	   => 5,						 // Number of castle limit result per page

save and exit.

now try your castle list

Edited by jupeto
  • Upvote 1
Posted

Got it working na without search function! final code below po,

in modules/castle/index.php copy below and replace your current castle index code


<?php
if (!defined('FLUX_ROOT')) exit;

$title = 'Castles';

// $sql  = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";
// $sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";

// $sth  = $server->connection->getStatement($sql);
// $sth->execute();

$sql  = "SELECT COUNT(castle_id) AS total FROM {$server->charMapDatabase}.guild_castle";

$sth  = $server->connection->getStatement($sql);

$sth->execute();
$paginator = $this->getPaginator($sth->fetch()->total,array('perPage'=>(int)Flux::config('CastleLimit')));

$sql  = "SELECT castles.castle_id, castles.guild_id, guild.name AS guild_name, guild.emblem_len FROM {$server->charMapDatabase}.guild_castle AS castles ";
$sql .= "LEFT JOIN guild ON guild.guild_id = castles.guild_id ORDER BY castles.castle_id ASC";

$sql  = $paginator->getSQL($sql);
$sth  = $server->connection->getStatement($sql);

$sth->execute();

$castles = $sth->fetchAll();
$castleNames = Flux::config('CastleNames')->toArray();

?>

save and exit.

in themes/your_theme_name/castle/index.php copy below and replace your current castle index code

<?php if (!defined('FLUX_ROOT')) exit; ?>
<h2>Castles</h2>
<p>This page shows what castles are activated and which guilds own them.</p>
<?php if ($castles): ?>
<?php echo $paginator->infoText() ?>
<table class="vertical-table">
<tr>
<th>Castle ID</th>
<th>Castle</th>
<th colspan="2">Guild</th>
</tr>
<?php foreach ($castles as $castle): ?>
<tr>
<td align="right"><?php echo htmlspecialchars($castle->castle_id) ?></td>
<td>
<?php if (array_key_exists($castle->castle_id, $castleNames) && $castleNames[$castle->castle_id]): ?>
<?php echo htmlspecialchars($castleNames[$castle->castle_id]) ?>
<?php else: ?>
<span class="not-applicable">Unknown<?php echo " (".$castle->castle_id.")" ?></span>
<?php endif ?>
</td>
<?php if ($castle->guild_name): ?>
<?php if ($castle->emblem_len): ?>
<td width="24"><img src="<?php echo $this->emblem($castle->guild_id) ?>" /></td>
<td>
<?php if ($auth->actionAllowed('guild', 'view') && $auth->allowedToViewGuild): ?>
<?php echo $this->linkToGuild($castle->guild_id, $castle->guild_name) ?>
<?php else: ?>
<?php echo htmlspecialchars($castle->guild_name) ?>
<?php endif ?>
</td>
<?php else: ?>
<td colspan="2"><?php echo htmlspecialchars($castle->guild_name) ?></td>
<?php endif ?>
<?php else: ?>
<td colspan="2"><span class="not-applicable"><?php echo htmlspecialchars(Flux::message('NoneLabel')) ?></span></td>
<?php endif ?>
</tr>
<?php endforeach ?>
</table>
<?php echo $paginator->getHTML() ?>
<?php else: ?>
<p>No castles found. <a href="javascript:history.go(-1)">Go back</a>.</p>
<?php endif ?>

save and exit.

in lib/Flux/Paginator.php

find

public function infoText()
{
 $currPage = $this->currentPage;
 $results  = Flux::config('ResultsPerPage');
 $infoText = sprintf(
  Flux::message('FoundSearchResults'),
  $this->total, $this->numberOfPages, ($currPage*$results-($results - 1)), $currPage * $results < $this->total ? ($currPage*$results) : ($this->total)
 );
 return sprintf('<p class="info-text">%s</p>', $infoText);
}

change to



public function infoText()
{
$currPage = $this->currentPage;
// $results  = Flux::config('ResultsPerPage');
$results  = $this->perPage;
$infoText = sprintf(
Flux::message('FoundSearchResults'),
$this->total,
$this->numberOfPages,
($currPage*$results-($results - 1)),
$currPage * $results < $this->total ? ($currPage*$results) : ($this->total)
);
return sprintf('<p class="info-text">%s</p>', $infoText);
}

save and exit.

in config/application.php

find

'CharRankingLimit'	=> 10,						//

add above

'CastleLimit'	   => 5,						 // Number of castle limit result per page

save and exit.

now try your castle list

Tnx sir. it works now ^^ more power

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...