• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Sortovanie vo foreach
PostPosted: Sun Aug 19, 2012 10:24 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
Zdravim

Da sa menu vygenerovat napr. podla ratingu od najlespieho po najhorsi (inak povedane da sa vo foreach sortovat napr. podla content block rating)?

tym ratingom myslim ze mam vytvoreny content block rating
Stranka A ma rating 50
B ma rating 30
C rating 80

a ja chcem aby mi menugenerator pekne vygeneroval menu zoradene podla tohoto ratingu (od najlepsieho po najhorsi) teda
C
A
B

lebo nikde som to nenasiel, tu je vychytavka ako sa da sortovat abecedne menutext http://www.i-do-this.com/blog/69/Sortin ... in-foreach


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Sat Nov 03, 2012 11:04 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
takze podla
http://www.i-do-this.com/blog/69/Sorting-items-in-foreach
sa na triedenie vo foreach daju pouzit iba premenne z {$nodelist|print_r} ako [id] [menutext] [extra1] atd?

neviete niekto ci sa da pouzit na triedenie (aby zobrazovalo polozky podla vysky hodnotenia) napr.
\$1:
{$cgsimple->get_page_content($node->alias,'rating')}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Sun Nov 04, 2012 10:38 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 10, 2006 5:00 pm
Posts: 448
Location: Bratislava
Vyuzi pole extra1.

Malo by stacit iba vo funkcii do_sort zamenit menutext za extra1

\$1:
 function do_sort($a, $b) {
        return $a->extra1 > $b->extra1;
    }}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Sun Nov 04, 2012 11:28 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
dik
a neda sa nejako priradit {$cgsimple->get_page_content($node->alias,'rating')} do extra1

vies aby extra1 zobrazovalo ten isty obsah ako content block rating

ci to sa neda?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Sun Nov 04, 2012 11:38 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 10, 2006 5:00 pm
Posts: 448
Location: Bratislava
Vsetko sa da, ked sa chce. Ale dal som ti funkcne riesenie, a nebudem ti pomahat s ugly horsim riesenim:)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Mon Nov 05, 2012 8:55 am 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
ja som ti zan vdacny ale
tu ani tak nejde ze by to bolo ugly riesenie ale pre mna by bolo funkcne pretoze ten rating je block modulu advanced content, ktory je dropdown a ma block_tab='Hodnotenie'


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Tue Nov 13, 2012 9:52 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 10, 2006 5:00 pm
Posts: 448
Location: Bratislava
Jo pozrem sa na to :)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Mon Nov 19, 2012 10:15 am 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
kuzmany \kuzmany:
Jo pozrem sa na to :)


dik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Fri Jan 11, 2013 10:47 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
nie je to toto?
http://forum.cmsmadesimple.org/viewtopic.php?f=4&t=64306


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Fri Jan 11, 2013 11:58 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 10, 2006 5:00 pm
Posts: 448
Location: Bratislava
Vytvoril by som si pouzivatelsky tag nodelist_assign

\$1:

if(!isset($params['nodelist']) || !is_array($params['nodelist'])  || !isset($params['block']) ||  !isset($params['assign']))
return;

$smarty = cmsms()->GetSmarty();
$contentops = cmsms()->GetContentOperations();


$nodelist = $params['nodelist'];
$block = $params['block'];
foreach($nodelist as $key=>$node){
$content = $contentops->LoadContentFromAlias($node->alias);
if( is_object($content) )
   $nodelist[$key]->$block  = $content->GetPropertyValue($block);
     
}

$smarty->assign($params['assign'], $nodelist);


Na zaciatok menu sablony by si mal dat

\$1:
{nodelist_assign nodelist=$nodelist block='nazovblockubezpodivinskychznakov' assign='nodelist'}


Podla toho navodu by si mal potom upravit do_sort (http://www.i-do-this.com/blog/69/Sortin ... in-foreach):

\$1:

 function do_sort($a, $b) {
        return $a->nazovblockubezpodivinskychznakov> $b->nazovblockubezpodivinskychznakov;
    }}



Fakin skript sa stara aby ti pridal do $nodelist pola dalsi parameter na zaklade tvojho blocku (napr. hodnotenie) a to potom dokazes zosortovat podla navodu. To uz zvladnes snad ;)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Sortovanie vo foreach
PostPosted: Mon Jan 21, 2013 1:22 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 206
diky moc

funguje jak oci :o


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting