Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Item Manager Extended (Beta)
#51
That seems to have fixed the problem.

In amongst downloading a bunch of plugins I overlooked that the current version is at Github. That's a problem with providing a link to download only an outdated version from GetSimple.
Reply
#52
Hello,

I want to report some bugs, I have problem with sortby function, and I dont know how to adjust it. I named Items with numbers only 1,2,3,.. but in admin area and in output i always see it descending, alhought I set sortby title. I was only updating function provided by you in first post.

Also I have a problem when updating items, I use 3 dropdownlists and on the 2 of them: when I update Item, it always switches dropdown to first position. I have to mention that I have no default value selected. One is Ok, there I only select a number. May there be a problem that I use a non english characters??? For example: +ľščťžýáíé

Thank you in advance.
Reply
#53
(2013-11-23, 05:36:55)smooo3 Wrote: Hello,

I want to report some bugs, I have problem with sortby function, and I dont know how to adjust it. I named Items with numbers only 1,2,3,.. but in admin area and in output i always see it descending, alhought I set sortby title. I was only updating function provided by you in first post.

Also I have a problem when updating items, I use 3 dropdownlists and on the 2 of them: when I update Item, it always switches dropdown to first position. I have to mention that I have no default value selected. One is Ok, there I only select a number. May there be a problem that I use a non english characters??? For example: +ľščťžýáíé

Thank you in advance.

And I must say: It is interesting, that after I added a letter it started to sort, but number only titles are always meesed up. (Maybe will help you...)
Reply
#54
(2013-11-23, 05:36:55)smooo3 Wrote: I want to report some bugs, I have problem with sortby function, and I dont know how to adjust it. I named Items with numbers only 1,2,3,.. but in admin area and in output i always see it descending, alhought I set sortby title. I was only updating function provided by you in first post.

Hi smooo3, thanks a lot for your report.
For a test I have created a few items named 1, 6, 3, 5, 4, 2 and it seems to sort the item order very well:

[Image: Bildschirmfoto%2520vom%25202013-11-23%25...253A39.png]

I don't think that's a bug it's a matter of opinion ascending or descending. But you are right, string title and a number title are treated differently:

[Image: Bildschirmfoto%2520vom%25202013-11-23%25...253A14.png]

If you assign strings to the title field your items will be displayed ascending instead of descending order, it's a real bug and I will change it in one of the next releases. My plan is to implement a new sort functionality to settings to change the items order manually.

But if you really need a quick solution, you can edit "im.model.class.php" file. Look for the "sort_array()" method, there you can replace the line that says
PHP Code:
if($a<$b
with the following:
PHP Code:
if($a>$b


(2013-11-23, 05:36:55)smooo3 Wrote: Also I have a problem when updating items, I use 3 dropdownlists and on the 2 of them: when I update Item, it always switches dropdown to first position. I have to mention that I have no default value selected. One is Ok, there I only select a number. May there be a problem that I use a non english characters??? For example: +ľščťžýáíé

I've been giving this a try and it seems to working well.
For a test I have created a category with 4 dropdown lists in different languages:

[Image: Bildschirmfoto%2520vom%25202013-11-23%25...253A25.png]

and item update has always worked well for me:

[Image: Bildschirmfoto%2520vom%25202013-11-23%25...253A19.png]

I can't find this bug and hope you can help me out. Can you be more specific about this issue?

thx
Reply
#55
Hi Bigin, thanks for your answer.
My problem shown::

I have a item settings set like this:
[Image: my-dropdowns.jpg]
The Item looks like this:
[Image: but-it-was-saved-like-this.jpg]
But on edit page it looks like this:
[Image: my-item-on-edit-click.jpg]

So now I don´t know, it is annoying to allways again set the things I don´t need to change, but I have to in order to have it same as it was.

I hope this helps to see my point. Thank you
Reply
#56
I have looked at the images you posted, but i can't see where "Voľný" value is set. It appears you may have forgotten to enter the value "Voľný" in dropdown list so it can not be selected.

[Image: my-dropdowns.jpg]
Reply
#57
Jop, I am sorry, but there is such option there, it is fourth in the list, so it is not visible.

As you see also the street changes on edit screen, and it is annoying to always change it, because sonetimes I forget Big Grin
Reply
#58
I have fixed the "strip quotes" bug. Please try the new version on github: https://github.com/bigin/imanager/archive/master.zip
Regards
Reply
#59
(2013-11-30, 03:34:31)Bigin Wrote: I have fixed the "strip quotes" bug. Please try the new version on github: https://github.com/bigin/imanager/archive/master.zip
Regards
I am sorry, but situation is as it was before this update on my page. Sad But it is OK, i got used to this functionality Smile Have a nice day.
sm3
Reply
#60
Hi Bigin,

Thanks for the plugin, I think it's excellent.

There are a couple of things I'd like help with/to suggest for future versions:

- Can you sort item lists by date (and specifically an arbitrary date that you set yourself, not just the date it was created)?

- Could there be an expiry date on items so that they automatically disappear when on the date specified?

- Is there, or in future versions will there be, any way of adding the same item to multiple categories?

Thanks,

David
Reply
#61
Thanks for dropping your comment David!

(2014-03-05, 20:38:44)ItalianDavid Wrote: - Can you sort item lists by date (and specifically an arbitrary date that you set yourself, not just the date it was created)?

Do you mean "sort item lists" in frontend?
If so, you can use a model method setPref():
PHP Code:
ImModel::setPref('sortby''your_field_name'); 

If you are going to sort items in back-end, you have to edit "/data/other/imanager.xml" file. There you can change node element <bsortby>title</bsortby> with your field name.

(2014-03-05, 20:38:44)ItalianDavid Wrote: - Could there be an expiry date on items so that they automatically disappear when on the date specified?

To hide items until a certain date you can use visibility_change() method.
But maybe it's a better idea to create a component-controller that only shows the items that are within the expiration date? Something like:

PHP Code:
foreach($pagedata['itemkeys'] as $key)
{
    if(
$items[$key]['my_date'] < $your_maximum_date)
    {
           echo 
$items[$key]['my_item'];
    }


(2014-03-05, 20:38:44)ItalianDavid Wrote: - Is there, or in future versions will there be, any way of adding the same item to multiple categories?

Currently not possible, however, maybe in a future version.

Regards
Reply
#62
Hi, when I try to add an image nothing happens and firebug shows this:

SyntaxError: malformed hexadecimal character escape sequence
window.open('http://localhost/C:\xampp\htdocs\GetSimpleCMS-3.3.0\plugins

What can I do?
Thanks
Reply
#63
Hello
its known bug, you should try a latest version from GitHub:
https://github.com/bigin/imanager
Reply
#64
(2014-04-22, 04:52:49)Bigin Wrote: Hello
its known bug, you should try a latest version from GitHub:
https://github.com/bigin/imanager


Now works perfect, thank you!
Reply
#65
how to get latest 5 or maybe 10 items from all categories ?
how to sort by DESC ? i'm was try a:
ImModel:ConfusedetPref('gsortby', 'title');
but it's not working

how to sort by add date ex: by time added
i'm was try a sort menu by asc
PHP Code:
<?php
$manager 
= new ImController();
$preferences imModel::getPref();

// Register your link template
$manager->tplRegister(array(
              
'loop' => '<a title="Click to go to category..." 
                   href="[[ my_group_url ]]">[[ my_group_title ]]</a><br />'
));

foreach(
$preferences->categories->category as $cat)
{
    
// setup items by category
    
ImCategory::setCategory($cat);
    
$manager->runModelMethod('gen_register', array('group_url''group_title'));
    
$items $manager->getModelValue('items_ordered_struct');
    
// Render your link template
    
echo   $manager->paint('loop', array(
                
'my_group_url' => $items[0]['group_url'], 
                
'my_group_title' => $items[0]['group_title']
    ));
}
?>
how to sorted menu by asc / dsc ?
it's possible to add a number of items what have a category ? example:
category one (24 items)
category two (two items)
user plugin: scroll to top
Reply
#66
The most things are possible with Item Manager you just have to know how to do it.

I have thoroughly tested the 'sortby' functionality of IM and can say that it worked fine. It seems to me that you have done something wrong. By the way, the function should called:
Code:
ImModel::setPref('sortby', 'title')

and not
Code:
ImModel::setPref('gsortby', 'title').



Ok, I'll show you a quick example:

Our goal is to get latest 10 items per category and show them in descending order.

1. Create your categories, we call it 'fruits' and 'vegetables'

[Image: Screenshot%2520from%25202014-06-14%25201...253A55.png]

2. You will need at least one field (in both categries) we call it 'sort_by_date'

[Image: Screenshot%2520from%25202014-06-14%25201...253A28.png]

3. You can now create your Items

In your case the Controller-Component should look as shown below

categorie_lister
PHP Code:
<?php
// get our controller parameter
global $args;
// check if order is desc
$order = ( isset($args[1]) && strtolower($args[1]) == 'desc' ) ? true false;
// get number of items displayed per category
$items_per_cat =  isset($args[0]) ? $args[0] : 10;

// define output
$output '';
 
// initialize controller
$manager = new ImController();
// get IManager preferences
$preferences imModel::getPref();

/* 
* Register our  templates 
* 1. Wrapper 
* 2. Row-Element template 
*/
$manager->tplRegister(array(
    
'cat-wrapper' =>
        
'<div class="cat-wrapper"><h3>[[ cat ]] <span>([[ item-count ]])</span></h3>[[ item-element ]]</div>',
    
'item-element'  => 
        
'<div class="item"><p>[[ title ]]</p><p>Characteristics: [[ characteristics ]]</p><p>Date: [[ date ]]</p></div>'
    
)
);


foreach(
$preferences->categories->category as $cat)
{
    
// setup items by category
    
ImCategory::setCategory($cat);
    
ImModel::setPref('sortby''sort_by_date');
    
$manager->runModelMethod'gen_register'
        array(
'sort_by_date''characteristics')
    );

    
// Check order
    // DESC 
    
if($order)
        
$items array_reverse($manager->getModelValue('items_ordered_struct'));
    
// ASC
    
else
        
$items $manager->getModelValue('items_ordered_struct'); 
    
    
// get number of items per categorie
    
$item_count count($items);
    
$ipc = ($item_count $items_per_cat) ? $items_per_cat $item_count;
    
    
$row '';
    for(
$i 0$i $ipc$i++)
    {
        
// Render your row template 
       
$row .= $manager->paint('item-element'
           array(
'title' => $items[$i]['title'], ' characteristics' => $items[$i]['characteristics'], 'date' => $items[$i]['sort_by_date'])
        );
    }
    
    
// Render wrapper template
    
$output .= $manager->paint('cat-wrapper'
        array(
'item-count' => $item_count'cat' => $cat'item-element' => $row)
    );
}
echo 
$output
?>


to call controller in frontend you can use DynPages-Plugin:

{% categorie_lister 10 DESC %}

The first parameter is the number of Items to show per category and the second is the sort by option.

And if you did this correctly the output should looks something like this:

[Image: Categories%2520List%2520%2520%2520imanager.png]
Reply
#67
thanks.. it's a this what i want.. but i'm trying to do it without a tpl
i'm get code:
PHP Code:
// get our controller parameter
global $args;

// get number of items displayed per category
$items_per_cat =  isset($args[0]) ? $args[0] : 10;

// define output
$output '';
 
// initialize controller
$manager = new ImController();
// get IManager preferences
$preferences imModel::getPref();



foreach(
$preferences->categories->category as $cat)
{
    
// setup items by category
    
ImCategory::setCategory($cat);
    
ImModel::setPref('sortby''date');
    
$manager->runModelMethod'gen_register'
        array(
'title''tresc')
    );


       
$items array_reverse($manager->getModelValue('items_ordered_struct'));
    
// ASC
         // $items = $manager->getModelValue('items_ordered_struct'); 
        
        // get number of items per categorie
    
$item_count count($items);
    
    
$ipc = ($item_count $items_per_cat) ? $items_per_cat $item_count;
    
$row '';
    for(
$i 0$i $ipc$i++)
    {
          
    
$informacja_tytul[$i]= $items[$i]['title'];
    
$data[$i]= $items[$i]['date'];
    
$kategoria[$i]= $cat[$i];
    
$sortuj$items[$i]['date'];
    echo 
'kkk ' .$args;
      echo 
'kategoria: '.$kategoria[$i] . '    &nbsp; &nbsp;&nbsp;   '.$informacja_tytul[$i] . ' &nbsp;&nbsp;&nbsp;data: '.$data[$i] . '<br />';

    }




it's working.. i'm get back a all categories what is sorted by date
https://dl.dropboxusercontent.com/u/4998...sort--.jpg.
But all categories is sorted first: by category, seccond by date
it's possible to get only 5 item's from all categories sorted by date..
without a categories. only 5 last added items...

i'm using a functions.php file in template folder Smile
and i'm loading this function by template... it's working..
please help.. thank you in advance
user plugin: scroll to top
Reply
#68
just a side note, why do you use $data[$i]= $items[$i]['date']; ? why not just $data= $items[$i]['date']; ?
Reply
#69
(2014-06-16, 19:30:31)morvy Wrote: just a side note, why do you use $data[$i]= $items[$i]['date']; ? why not just $data= $items[$i]['date']; ?


good question... i'm was try to sort it after the "for" in other (new) for... but it was to hard for me ;(
user plugin: scroll to top
Reply
#70
Hello,


(2014-06-16, 19:24:12)xxdex Wrote: it's possible to get only 5 item's from all categories sorted by date..
without a categories. only 5 last added items...

i'm using a functions.php file in template folder Smile
and i'm loading this function by template... it's working..
please help.. thank you in advance

hmmm... OK.
If you only try to show last 5 items sorted by release date, you can use this function in your functions.php file for example:

PHP Code:
function sort_array($a$b)
{
    if (
$a['date'] == $b['date'])
    {
        return 
0;
    }
    else
    {
        if(
$a['date'] < $b['date'])
        { 
            return 
1;
        }
        else
        {
            return -
1;
        }
    }


And your Controller might then look like this:

PHP Code:
// get max number of items displayed 
$items_max 5
// initialize controller
$manager = new ImController();
// get IManager preferences
$preferences imModel::getPref();

$items_arr = array();
foreach(
$preferences->categories->category as $cat)
{
    
// setup items by category
    
ImCategory::setCategory($cat);
    
$manager->runModelMethod('gen_register');
    
// get all your items no matter what category
    
$items $manager->getModelValue('items_ordered_struct');
    
$items_arr array_merge($items_arr$items);
}

$item_count count($items_arr);
$ipc = ($item_count $items_max) ? $items_max $item_count;

// There your "sort_array" function call
usort($items_arr'sort_array');

for(
$i 0$i $ipc$i++)
{
    echo 
'<strong>Published on:</strong> ' $items_arr[$i]['date'] . ' <strong>Title:</strong> ' $items_arr[$i]['title'] . '<br />';



By the way, it's not necessary to register standard fields like "title" or "date", etc, you should do it only if you use custom fields like "tresc":

(2014-06-16, 19:24:12)xxdex Wrote: $manager->runModelMethod( 'gen_register',
array('title', 'tresc')
);

Better:

PHP Code:
$manager->runModelMethod'gen_register', array('tresc')); 

To dispay all standard fields of your items just use:

PHP Code:
$items $manager->getModelValue('items_ordered_struct');
var_dump($items); 

Regards
Reply
#71
Ohh... I forgot to explain that we have date as a string e.g. "17 Jun 2014"
The task is, to turn a string giving a date and into a timestamp.
You can do it with strtotime() for example. So your sort_array() function would then look as follows:

PHP Code:
function sort_array($a$b)
{
    
$a strtotime($a['date']);
    
$b strtotime($b['date']);

    if (
$a == $b)
    {
        return 
0;
    }
    else
    {
        if(
$a $b)
        { 
            return 
1;
        }
        else
        {
            return -
1;
        }
    }

Reply
#72
thank You Bigin!!! very much thanks!
several question:
1. it's possible to change a upload manager to pgrfilemanager?
http://pgrfilemanager.sourceforge.net/
i'm was try to do it... but with problem because i don't know how after select in pgrfilemanager a img file. to input it into a field.
2. it's possible to change a category name?
user plugin: scroll to top
Reply
#73
i'm trying a sort a categories in front-end by asc but i can't do it ;(
i'm trying do it the third day without any progress.
can some on help with it?

i'm do it in functions.php file in template
i want to get a:
acat (2 items)
bcat (3 items)
4cat (2 items)

please help with sort it ;(

i'm working at a polish language for this plugin. ;-)
user plugin: scroll to top
Reply
#74
What have you tried , what is not working ?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#75
(2014-06-24, 02:41:14)shawn_a Wrote: What have you tried , what is not working ?

PHP Code:
function cateogory_list() {
    
// get our controller parameter
global $args;

// get number of items displayed per category
$items_per_cat =  isset($args[0]) ? $args[0] : 10;

// define output
$output '';
 
// initialize controller
$manager = new ImController();
// get IManager preferences
$preferences imModel::getPref();


foreach(
$preferences->categories->category as $cat)
{
    
// setup items by category
    
ImCategory::setCategory($cat);

    
$manager->runModelMethod'gen_register'
        array(
'''')
    );

   
      
$items array_reverse($manager->getModelValue('items_ordered_struct'));

          
$items_arr array_merge($items_arr$items);

    
    
// get number of items per categorie
    
$item_count count($items);
    
$ipc = ($item_count $items_per_cat) ? $items_per_cat $item_count;
    
    
$row '';

    for(
$i 0$i $ipc$i++)
    {
    
    }
    
    
// Render wrapper template
    // THIS LINE IS IMPORTANT --> i getting a category from here
     
echo '<a class=" aa" title="'.$items[0]['category'].'"  href="nasza-oferta?kategoria='.$items[0]['category'].'">'.$items[0]['category'].' ('.$item_count.')</a><br />';

}         





i'm was trying too do this with a code to

PHP Code:
function sort_array_cat($a$b)
{
    if (
$a['category'] == $b['category'])
    {
        return 
0;
    }
    else
    {
        if(
$a['category'] < $b['category'])
        { 
            return 
1;
        }
        else
        {
            return -
1;
        }
    }

but this is not working...
i want to sorting a category list by asc or desc - this plugin not have a custom sorting name of categories.. and it's display it by the created date.
i can sort a categories.. THANK YOU Bigin
but i have a difficult problem with sorting a categories with asc dsc...
user plugin: scroll to top
Reply




Users browsing this thread: 1 Guest(s)