Jump to content

Ordering attributes within a node: Difference between revisions

From NusaATK
No edit summary
No edit summary
 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{howto|Basic|[[Ivo Jansch]] <ivo@achievo.org>}}
==Ordering attributes within a node==
==Ordering attributes within a node==
By default, the order in which attributes appear in a node is based on the order in which they are added to it. You can influence this however by passing a positive integer as third parameter to atkNode's add() method.
If you don't pass this parameter, ATK will use increments of 100, starting with 100 for the first atttribute. So if you add an attribute later on, and want it to appear between the first and second attribute, pass 150 as third parameter, like this:
<pre>
$this->add(new atkAttribute("value"), NULL, 150);
</pre>
Original Poster: Ivo
<div  style="display:none">
[We are delicate. We do not delete your content.]
[l_sp20]
[http://www.buddyprofile.com/viewprofile.php?username=waterfordcrystal waterford crystal]
[http://www.buddyprofile.com/viewprofile.php?username=swarovskicrystal swarovski crystal bead]
[http://www.buddyprofile.com/viewprofile.php?username=mesotheliomalawsuits mesothelioma lawsuits]
[http://www.buddyprofile.com/viewprofile.php?username=mesotheliomasymptoms mesothelioma symptoms]
[http://www.buddyprofile.com/viewprofile.php?username=mesotheliomadiag mesothelioma diagnosis]
[http://www.buddyprofile.com/viewprofile.php?username=wacoalbras wacoal bras]
[http://www.buddyprofile.com/viewprofile.php?username=teenbra teen bra]
[http://www.buddyprofile.com/viewprofile.php?username=unsecuredloan unsecured signature loan]
[http://www.buddyprofile.com/viewprofile.php?username=homeloans Countrywide Home Loans]
[http://blog.moddingplanet.it/?w=formalpromdresses Formal Prom Dresses]
[http://blog.moddingplanet.it/?w=sexypromdress Sexy Prom Dress]
[http://blog.moddingplanet.it/?w=cocktaildresses cocktail dresses]
[http://www.buddyprofile.com/viewprofile.php?username=telmobile TMobile]
[http://www.buddyprofile.com/viewprofile.php?username=watersoftener water softener]
[http://www.buddyprofile.com/viewprofile.php?username=tanklesswaterheater tankless water heater]
[http://www.buddyprofile.com/viewprofile.php?username=rockportshoes rockport shoes]
[http://www.buddyprofile.com/viewprofile.php?username=osmosiswaterfilter reverse osmosis water filter]
[http://www.buddyprofile.com/viewprofile.php?username=merrellshoes merrell shoes]
[http://www.buddyprofile.com/viewprofile.php?username=oscardresses oscar dresses]
[http://www.buddyprofile.com/viewprofile.php?username=easterdresses easter dresses]
[http://flyfone.blox.pl/resource/flyfonevoip.htm flyfone voip]
[http://www.buddyprofile.com/viewprofile.php?username=plussizepromdresses plus size prom dresses]
[http://www.buddyprofile.com/viewprofile.php?username=discountpromdresses discount prom dresses]
[http://blog.moddingplanet.it/?w=hooterscasinolas Hooters Casino Las Vegas]
[http://blog.moddingplanet.it/?w=grandcasinomille grand casino mille lacs]
[http://blog.moddingplanet.it/?w=lasvegascasino las vegas casino coupons]
[http://blog.moddingplanet.it/?w=onlinepokeraide online poker aide]
[http://www.donx.de/blog/pechangacasino pechanga casino]
[http://www.donx.de/blog/grandvictoriacasino/ grand victoria casino]
[http://www.donx.de/blog/ballgowns/ ball gowns]
[http://www.privetparis.com/blog/rtgcasinobonus/ rtg casino bonus]
[http://blog.moddingplanet.it/?w=rtgcasinobonus rtg casino bonus]
[http://blog.moddingplanet.it/?w=grandcasinocoushat grand casino coushatta]
[http://blog.moddingplanet.it/?w=grandcasinohinckle grand casino hinckley]
[http://blog.moddingplanet.it/?w=isleofcapricasino isle of capri casino]
[http://blog.moddingplanet.it/?w=mohegansuncasino mohegan sun casino]
[http://blog.moddingplanet.it/?w=palacasino pala casino]
[http://blog.moddingplanet.it/?w=roulettewheels roulette wheels]
[http://blog.moddingplanet.it/?w=winstarcasino winstar casino]
[http://blog.moddingplanet.it/?w=cheappromdresses Cheap Prom Dresses]
[http://blog.moddingplanet.it/?w=informalweddingdre informal wedding dresses]
[http://blog.moddingplanet.it/?w=oscardresses oscar dresses]
[http://blog.moddingplanet.it/?w=eveninggowns evening gowns]
[http://vvvvvv.blox.pl/resource/throat_pokers.htm throat pokers]
[http://vvvvvv.blox.pl/resource/online_poker_assistant.htm online poker assistant]
[http://vvvvvv.blox.pl/resource/online_poker_tracker.htm online poker tracker]
[http://vvvvvv.blox.pl/resource/online_poker_aide.htm online poker aide]
[http://vvvvvv.blox.pl/resource/party_poker_bonus.htm party poker bonus]
[http://vvvvvv.blox.pl/resource/party_poker_bonus_code.htm party poker bonus code]
[http://vvvvvv.blox.pl/resource/bonus_code_party_poker.htm bonus code party poker]
[http://vvvvvv.blox.pl/resource/bonus_code_deposit_party_poker.htm bonus code deposit party poker]
[http://vvvvvv.blox.pl/resource/party_poker_bonus_codes.htm party poker bonus codes]
[http://vvvvvv.blox.pl/resource/carnival_cruises.htm carnival cruises]
[http://vvvvvv.blox.pl/resource/carnival_game_rentals.htm carnival game rentals]
[http://vvvvvv.blox.pl/resource/fuzzydice.htm fuzzy dice]
[http://vvvvvv.blox.pl/resource/bingodaubers.htm bingo daubers]
[http://vvvvvv.blox.pl/resource/bingoblowers.htm bingo blowers]
[http://vvvvvv.blox.pl/resource/motor_scooters.htm motor scooters]
[http://vvvvvv.blox.pl/resource/mini_harley_chopper_scooter.htm mini harley chopper scooter]
[http://blog.moddingplanet.it/?w=fakerolex fake rolex]
[http://blog.moddingplanet.it/?w=bextravioxx bextra vioxx]
[http://blog.moddingplanet.it/?w=zocor zocor]
[http://blog.moddingplanet.it/?w=zithromax zithromax]
[http://blog.moddingplanet.it/?w=bextralawyernew bextra lawyer new hampshire]
[http://blog.moddingplanet.it/?w=akanesoma akane soma]
[http://blog.moddingplanet.it/?w=kyosoma kyo soma]
[http://blog.moddingplanet.it/?w=prozacnation prozac nation]
[http://blog.moddingplanet.it/?w=prozacwithdrawal prozac withdrawal]
[http://blog.moddingplanet.it/?w=simslots sim slots]
[http://blog.moddingplanet.it/?w=pachisloslotmachine pachislo slot machines]
[http://blog.moddingplanet.it/?w=programcherries program cherries wild slot machine]
[http://blog.moddingplanet.it/?w=slotcarracing slot car racing]
[http://blog.moddingplanet.it/?w=hoslotcars ho slot cars]
http://www.vinniky.org.ua/upload/index.php?action=downloadfile&filename=discount-paxil.html
[http://blog.moddingplanet.it/?w=bingocages bingo cages]
[http://blog.moddingplanet.it/?w=bingodaubers bingo daubers]
[http://blog.moddingplanet.it/?w=bingoblowers bingo blowers]
[http://blog.moddingplanet.it/?w=bingobags bingo bags]
[http://blog.moddingplanet.it/?w=baccaratcrystal baccarat crystal]
[http://blog.moddingplanet.it/?w=nexium nexium]
[http://blog.moddingplanet.it/?w=onlinepaigowpoker online pai gow poker]
[http://blog.moddingplanet.it/?w=leighkeno leigh keno]
</div>


If you have an <tt>atkNode</tt>, attributes (i.e. database columns) appear in the order in which they are added via <tt>atkNode::add()</tt>.


If you have an <tt>atkMetaNode</tt> (or derived class), fields appear in the order in which they appear in the database. To control the order in which attributes appear within a node (i.e. on a "page"), use <tt>atkMetaPolicy::setOrder()</tt>, <tt>atkMetaPolicy::setIncludes()</tt> or the <tt>$order</tt> argument to either <tt>atkMetaNode::add()</tt> or <tt>atkMetaPolicy::add()</tt>.  If you don't have access to an <tt>atkMetaPolicy</tt>, use <tt>atkMetaNode::setAttributeOrder()</tt>.


===Examples===


<div  style="display:none">
With <tt>atkMetaPolicy</tt>:
[We are delicate. We do not delete your content.]
[l_sp23]


<syntaxhighlight lang="php">
public static function meta(atkMetaPolicy $policy)
{
  $policy->add("invoice_start_date", "atkDateAttribute");
  $policy->add("invoice_end_date", "atkDateAttribute");


[http://blog.moddingplanet.it/?w=formalpromdresses Formal Prom Dresses]
  $policy->setOrder(array(
[http://blog.moddingplanet.it/?w=sexypromdress Sexy Prom Dress]
    "invoice_start_date",
[http://blog.moddingplanet.it/?w=cocktaildresses cocktail dresses]
    "invoice_end_date"
[http://flyfone.blox.pl/resource/flyfonevoip.htm flyfone voip]
  ));
[http://blog.moddingplanet.it/?w=hooterscasinolas Hooters Casino Las Vegas]
}
[http://blog.moddingplanet.it/?w=grandcasinomille grand casino mille lacs]
</syntaxhighlight>
[http://blog.moddingplanet.it/?w=lasvegascasino las vegas casino coupons]
[http://blog.moddingplanet.it/?w=onlinepokeraide online poker aide]
[http://www.donx.de/blog/pechangacasino pechanga casino]
[http://www.donx.de/blog/grandvictoriacasino/ grand victoria casino]
[http://www.donx.de/blog/ballgowns/ ball gowns]
[http://www.privetparis.com/blog/rtgcasinobonus/ rtg casino bonus]


[http://blog.moddingplanet.it/?w=rtgcasinobonus rtg casino bonus]
Using <tt>[[atkMetaAttributeModifier]]</tt> attribute modifiers:
[http://blog.moddingplanet.it/?w=grandcasinocoushat grand casino coushatta]
[http://blog.moddingplanet.it/?w=grandcasinohinckle grand casino hinckley]
[http://blog.moddingplanet.it/?w=isleofcapricasino isle of capri casino]
[http://blog.moddingplanet.it/?w=mohegansuncasino mohegan sun casino]
[http://blog.moddingplanet.it/?w=palacasino pala casino]
[http://blog.moddingplanet.it/?w=roulettewheels roulette wheels]
[http://blog.moddingplanet.it/?w=winstarcasino winstar casino]
[http://blog.moddingplanet.it/?w=cheappromdresses Cheap Prom Dresses]
[http://blog.moddingplanet.it/?w=informalweddingdre informal wedding dresses]
[http://blog.moddingplanet.it/?w=oscardresses oscar dresses]
[http://blog.moddingplanet.it/?w=eveninggowns evening gowns]


[http://vvvvvv.blox.pl/resource/throat_pokers.htm throat pokers]
<syntaxhighlight lang="php">
[http://vvvvvv.blox.pl/resource/online_poker_assistant.htm online poker assistant]
public static function meta(atkMetaPolicy $policy)
[http://vvvvvv.blox.pl/resource/online_poker_tracker.htm online poker tracker]
{
[http://vvvvvv.blox.pl/resource/online_poker_aide.htm online poker aide]
  // Make sure that field1 appears after field 2
[http://vvvvvv.blox.pl/resource/party_poker_bonus.htm party poker bonus]
  $policy->get("field1")->insertAfter("field2");
[http://vvvvvv.blox.pl/resource/party_poker_bonus_code.htm party poker bonus code]
[http://vvvvvv.blox.pl/resource/bonus_code_party_poker.htm bonus code party poker]
[http://vvvvvv.blox.pl/resource/bonus_code_deposit_party_poker.htm bonus code deposit party poker]
[http://vvvvvv.blox.pl/resource/party_poker_bonus_codes.htm party poker bonus codes]
[http://vvvvvv.blox.pl/resource/carnival_cruises.htm carnival cruises]
[http://vvvvvv.blox.pl/resource/carnival_game_rentals.htm carnival game rentals]
[http://vvvvvv.blox.pl/resource/fuzzydice.htm fuzzy dice]
[http://vvvvvv.blox.pl/resource/bingodaubers.htm bingo daubers]
[http://vvvvvv.blox.pl/resource/bingoblowers.htm bingo blowers]
[http://vvvvvv.blox.pl/resource/motor_scooters.htm motor scooters]
[http://vvvvvv.blox.pl/resource/mini_harley_chopper_scooter.htm mini harley chopper scooter]
[http://blog.moddingplanet.it/?w=fakerolex fake rolex]


[http://blog.moddingplanet.it/?w=bextravioxx bextra vioxx]
  // Make sure the remark field appears at the bottom.
[http://blog.moddingplanet.it/?w=zocor zocor]
  $policy->get("remark")->insertAtBottom();
[http://blog.moddingplanet.it/?w=zithromax zithromax]
}
[http://blog.moddingplanet.it/?w=bextralawyernew bextra lawyer new hampshire]
[http://blog.moddingplanet.it/?w=akanesoma akane soma]
[http://blog.moddingplanet.it/?w=kyosoma kyo soma]
[http://blog.moddingplanet.it/?w=prozacnation prozac nation]
[http://blog.moddingplanet.it/?w=prozacwithdrawal prozac withdrawal]
[http://blog.moddingplanet.it/?w=simslots sim slots]
[http://blog.moddingplanet.it/?w=pachisloslotmachine pachislo slot machines]
[http://blog.moddingplanet.it/?w=programcherries program cherries wild slot machine]
[http://blog.moddingplanet.it/?w=slotcarracing slot car racing]
[http://blog.moddingplanet.it/?w=hoslotcars ho slot cars]


[http://blog.moddingplanet.it/?w=bingocages bingo cages]
See the [http://www.atk-framework.com/docs/atk/trunk/atk/meta/atkMetaAttributeModifier.html atkMetaAttributeModifier] API docs for more possibilities on reordering.
[http://blog.moddingplanet.it/?w=bingodaubers bingo daubers]
[http://blog.moddingplanet.it/?w=bingoblowers bingo blowers]
[http://blog.moddingplanet.it/?w=bingobags bingo bags]
[http://blog.moddingplanet.it/?w=baccaratcrystal baccarat crystal]
[http://blog.moddingplanet.it/?w=nexium nexium]
[http://blog.moddingplanet.it/?w=onlinepaigowpoker online pai gow poker]
[http://blog.moddingplanet.it/?w=leighkeno leigh keno]


[http://www.privetparis.com/blog/tramadol50mg/ tramadol 50mg]
</syntaxhighlight>
[http://www.privetparis.com/blog/tramadolsaturdaydelivery/ tramadol saturday delivery]
[http://www.privetparis.com/blog/tramadoler/ tramadol er]
[http://www.privetparis.com/blog/tramadolsales/ tramadol sales]
[http://www.privetparis.com/blog/tramadolhcl50mg/ tramadol hcl 50 mg]
[http://www.privetparis.com/blog/120tramadoll/ 120 tramadol]
[http://www.privetparis.com/blog/acetaminophenhclpartramadol/ acetaminophen hcl par tramadol]
[http://blog.moddingplanet.it/?w=plussizemother plus size mother of the bride dresses]
[http://blog.moddingplanet.it/?w=cheapflowergirl cheap flower girl dresses]
[http://blog.moddingplanet.it/?w=discountflowergirl discount flower girl dresses]
[http://blog.moddingplanet.it/?w=infantflowergirl infant flower girl dresses]
[http://blog.moddingplanet.it/?w=bridalflowergirl bridal flower girl dresses]


[http://blog.moddingplanet.it/?w=discountbridesmaid discount bridesmaid dresses]
[http://blog.moddingplanet.it/?w=juniorbridesmaid junior bridesmaid dresses]
[http://blog.moddingplanet.it/?w=cheapbridesmaid cheap bridesmaid dresses]
[http://blog.moddingplanet.it/?w=plussizebridesmaid plus size bridesmaid dresses]
[http://blog.moddingplanet.it/?w=weddingbridesmaid wedding bridesmaid dresses]
[http://blog.moddingplanet.it/?w=maternitybridesmaid maternity bridesmaid dresses]


[http://vvvvvv.blox.pl/resource/Rascal_Flatts_Me_And_My_Gang.htm Rascal Flatts Me And My Gang]
=== Independently ordering attributes on the "admin" and "view" pages ===
[http://vvvvvv.blox.pl/resource/NeYo__In_My_Own_Words.htm Ne-Yo  In My Own Words]
[http://vvvvvv.blox.pl/resource/Kelly_Clarkson_Breakaway.htm Kelly Clarkson Breakaway]


[http://blog.moddingplanet.it/?w=biaxin biaxin]
If you want your attributes to appear in one order in the "admin" (list) page, and in another in the "view" (detail) page, you can do something like the following to ensure that the "name" attribute will appear before the "email" attribute of "view" pages:
[http://blog.moddingplanet.it/?w=biaxinxl biaxin xl]
[http://blog.moddingplanet.it/?w=atenololsideeffect atenolol side effects]
[http://blog.moddingplanet.it/?w=flexeril flexeril]
[http://blog.moddingplanet.it/?w=diflucan diflucan]
[http://blog.moddingplanet.it/?w=glucophage glucophage]
[http://blog.moddingplanet.it/?w=tenuatedospan tenuate dospan]
[http://blog.moddingplanet.it/?w=zanaflex zanaflex]


[http://blog.moddingplanet.it/?w=acyclovirzovirax acyclovir zovirax]
<syntaxhighlight lang="php">
[http://blog.moddingplanet.it/?w=cyclobenzaprine cyclobenzaprine hcl]
  public function action_view($handler) {
[http://blog.moddingplanet.it/?w=clonazepamside clonazepam side effects]
    $this->setAttributeOrder("name", 10);
[http://blog.moddingplanet.it/?w=testosteronecream testosterone cream]
    $this->setAttributeOrder("email", 20);
[http://blog.moddingplanet.it/?w=celebrexvsvioxx celebrex vs vioxx]
    $this->attribSort();
[http://kilobax.eblog.pl/ infant flower girl dresses]
    $handler->action_view($handler);
[http://www.junior-bridesmaid-dresses.eblog.pl/ junior bridesmaid dresses]
  }
</syntaxhighlight>


[http://blog.moddingplanet.it/?w=eroticgamesstrip erotic games strip poker]
(Note that where they will appear in relation to the other attributes is dependent on the "order" value of the other attributes.)
[http://blog.moddingplanet.it/?w=strippokerstories strip poker stories]
[http://blog.moddingplanet.it/?w=adultstrippoker adult strip poker]
[http://blog.moddingplanet.it/?w=claypokerchips clay poker chips]
[http://blog.moddingplanet.it/?w=woodenpokerchip wooden poker chip cases]
[http://blog.moddingplanet.it/?w=custompokerchips custom poker chips]
[http://blog.moddingplanet.it/?w=pokerchiptricks poker chip tricks]
[http://blog.moddingplanet.it/?w=custommadepoker custom made poker chips]
[http://blog.moddingplanet.it/?w=throatpokers throat pokers]
[http://blog.moddingplanet.it/?w=pokerhandrankings poker hand rankings]
[http://blog.moddingplanet.it/?w=paigowpoker pai gow poker]
[http://blog.moddingplanet.it/?w=caribbeanstudpoker caribbean stud poker]
[http://blog.moddingplanet.it/?w=onlinepokerassista online poker assistant]
[http://blog.moddingplanet.it/?w=onlinepokertracker online poker tracker]
</div>

Latest revision as of 15:21, 16 March 2011

ATK Howto: Ordering attributes within a node

Complexity: Basic
Author: Ivo Jansch <ivo@achievo.org>

List of other Howto's

Ordering attributes within a node

If you have an atkNode, attributes (i.e. database columns) appear in the order in which they are added via atkNode::add().

If you have an atkMetaNode (or derived class), fields appear in the order in which they appear in the database. To control the order in which attributes appear within a node (i.e. on a "page"), use atkMetaPolicy::setOrder(), atkMetaPolicy::setIncludes() or the $order argument to either atkMetaNode::add() or atkMetaPolicy::add(). If you don't have access to an atkMetaPolicy, use atkMetaNode::setAttributeOrder().

Examples

With atkMetaPolicy:

public static function meta(atkMetaPolicy $policy) 
{
  $policy->add("invoice_start_date", "atkDateAttribute");
  $policy->add("invoice_end_date", "atkDateAttribute");

  $policy->setOrder(array(
    "invoice_start_date",
    "invoice_end_date"
  ));
}

Using atkMetaAttributeModifier attribute modifiers:

public static function meta(atkMetaPolicy $policy) 
{
  // Make sure that field1 appears after field 2
  $policy->get("field1")->insertAfter("field2");

  // Make sure the remark field appears at the bottom.
  $policy->get("remark")->insertAtBottom();
}

See the [http://www.atk-framework.com/docs/atk/trunk/atk/meta/atkMetaAttributeModifier.html atkMetaAttributeModifier] API docs for more possibilities on reordering.


Independently ordering attributes on the "admin" and "view" pages

If you want your attributes to appear in one order in the "admin" (list) page, and in another in the "view" (detail) page, you can do something like the following to ensure that the "name" attribute will appear before the "email" attribute of "view" pages:

  public function action_view($handler) {
    $this->setAttributeOrder("name", 10);
    $this->setAttributeOrder("email", 20);
    $this->attribSort();
    $handler->action_view($handler);
  }

(Note that where they will appear in relation to the other attributes is dependent on the "order" value of the other attributes.)