Reorder Articles like Categories in Backend

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
pWorker
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 31, 2016 1:30 pm

Reorder Articles like Categories in Backend

Post by pWorker »

Hi all,

first of all-> I really love cmsms and i have many happy clients 8)

Well, my actual project is really complex (at least for me) and there is a point, where my "customizing of cmsms module bricks" isn`t enough.

I`m using the FEU module (+SR), so that logged-in users (XD) can write news for specific categories. News, on my webpage, is an equivalent for content blocks (Templates for Reclame, Articles, Slider Content etc.).

But there has also to be a meta regular-user level ( for my client) where really all settings can be done. His wish is to reorder articles (so e.g. that a specific reclame is shown on top). For that I want to use the same "light-weight" solution like it`s done in the admin - category tab, where you can click on that small button to reorder cats.

I found a template named admin_reorder_cat.tpl , an action
action.admin_reorder_cat.tpl and the admin template for the articlelist articlelist.tpl.

My idea, via module_custom, is to call an action called action.admin_reorder_articles.tpl, based on admin_reorder_articles.tpl in modified articlelist.tpl.

What I think to know so far, is that the action action.admin_reorder_cat.tpl changes/ switches the id`s of the categories by rewriting their`s databank id-values.

My problem is, that news articles are saved differently from categories in the db, and i do not want to lost the connection between content and id neither the cmsms engine not to handle about so many news. There is also no "parent"-/"child"-relation between the articles, so that each Article only has to be treaten as simple list-element.

My question: Is there a way to do this?


articlelist.tpl:

Code: Select all

<div class="row">
  <div class="pageoptions half" style="margin-top: 8px;">
    <a id="toggle_filter" {if $curcategory != ''} style="font-weight: bold; color: green;"{/if}>{admin_icon icon='view.gif' alt=$mod->Lang('viewfilter')} {if $curcategory != ''}*{/if}{$mod->Lang('viewfilter')}</a>
    {if isset($addlink)}&nbsp;{$addlink}{/if}
    {if $itemcount > 1}<a href="{cms_action_url action='admin_reorder_articles'}" title="{$mod->Lang('reorder')}">{admin_icon icon='reorder.gif'} {$mod->Lang('reorder')}</a>{/if}
  </div>
</div>

Anyone ideas?
Thanks in advance.

Code: Select all


----------------------------------------------

Cms Version: 2.1.4

Installed Modules:

    AdminSearch: 1.0.1
    CGExtensions: 1.53.10
    CGSimpleSmarty: 2.1.2
    CGUserDirectory: 1.5
    CMSContentManager: 1.1
    CMSMailer: 6.2.14
    DesignManager: 1.1.1
    FileManager: 1.5.2
    FormBuilder: 0.8.1.4
    FrontEndUsers: 2.0.7
    Gallery: 2.1.6
    MicroTiny: 2.0.3
    ModuleManager: 2.0.2
    Navigator: 1.0.3
    News: 2.50.5
    Search: 1.50.2
    SelfRegistration: 1.9.6


Config Information:

    php_memory_limit:
    max_upload_size: 256000000
    url_rewriting: mod_rewrite
    page_extension:
    query_var: page
    auto_alias_content: true
    locale:
    set_names: true
    timezone: Europe/Berlin
    permissive_smarty: false


Php Information:

    phpversion: 7.0.10
    md5_function: An (Ja)
    json_function: An (Ja)
    gd_version: 2
    tempnam_function: An (Ja)
    magic_quotes_runtime: Aus (Nein)
    E_ALL: 32767
    E_STRICT: 2048
    E_DEPRECATED: 8192
    test_file_timedifference: No time difference found
    test_db_timedifference: No time difference found
    create_dir_and_file: 1
    memory_limit: 128M
    max_execution_time: 192
    register_globals: Aus (Nein)
    output_buffering: 4096
    disable_functions: exec, system, shell_exec, popen, pclose, proc_open, proc_close, proc_get_status, proc_nice, proc_terminate, show_source, escapeshellcmd, escapeshellarg
    open_basedir: /home/xxx/stats
    test_remote_url: Erfolgreich abgeschlossen
    file_uploads: An (Ja)
    post_max_size: 260M
    upload_max_filesize: 256M
    session_save_path: Keine Prüfung, da eine „open basedir“-Beschränkung aktiviert ist
    session_use_cookies: An (Ja)
    xml_function: An (Ja)
    xmlreader_class: An (Ja)
    check_ini_set: An (Ja)
    curl: An


Performance Information:

    allow_browser_cache: Aus (Nein)
    browser_cache_expiry: 60
    php_opcache: Aus (Nein)
    smarty_cache: Aus (Nein)
    smarty_compilecheck: Aus (Nein)
    smarty_cache_udt: Aus (Nein)
    auto_clear_cache_age: An (Ja)

Server Information:

    Server Software: Apache/2.4.10 (Debian)
    Server Api: cgi-fcgi
    Server Os: Linux 3.16.0-4-amd64 An x86_64
    Server Db Type: MySQL (mysqli)
    Server Db Version: 5.5.50
    Server Db Grants: Es konnte keine „GRANT ALL“-Berechtigung gefunden werden. Dies kann bedeuten, dass Sie bei der Installation oder beim Entfernen von Modulen, oder sogar beim Hinzufügen und Löschen von Elementen, einschließlich Seiten, Probleme haben könnten.


Permission Information:

    tmp: /home/xxx/tmp (0775)
    tmp_cache: /home/xxx/tmp/cache (0775)
    templates_c: /home/xxx/tmp/templates_c (0775)
    modules: /home/xxx/modules (0775)
    uploads: /home/xxx/uploads (0775)
    Maske zum Erstellen von Dateien (umask): /home/xxx/tmp/cache (0775)
    config_file: 0444

----------------------------------------------
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Reorder Articles like Categories in Backend

Post by calguy1000 »

Hi pWorker. and welcome.

Thank you for your very complete and well described question. It doesn't happen often. Keep it up.

To answer your question. There is no built-in way to prioritize news articles.... but there are some simple tweaks you can do if you're a bit comfortable with php. As with anything there are costs and benefits to every solution, it depends on your environment.

One method is via the news_extra field.
a: Use the 'extra' field in the News module to contain an alphabetic priority (alphabetic because the field is a string, and in ASCII '2' is > '19') or a number from 1 to 9.
b: optionally modify the editarticle.tpl via module_custom to change the label of the 'extra' field.
c: call news like: {News sortby='news_extra'}
-- advantages --
Works with pagination on the frontend, so it doesn't matter how many articles exist, or can be displayed.
-- disadvantages --
- The priority field has to be alphabetic... or from 1 to 9, or zero filled because of ASCII sorting.
- There is no method in the article list of the admin panel to view or sort by the news_extra field, so it's kinda like flying blind.

Another method is to use a custom field to hold the priority
----
a: Create a custom field called 'priority' , and store numbers between 1 and 100
b: Create a UDT that will be called in your summary template to 'post-query-sort' the articles that are provided to the summary view.
c: Display articles like normal.
-- advantages --
1. You don't need to worry about string sorting because your UDT can handle the sorting.
2. You need a bit (but not much) PHP knowledge
-- disadvantages --
1. There is no way in the articlelist to view the custom field, or to sort or filter on it.
2. This is a post-query-sort method.... so it will only re-sort the articles already provided to the summary view. Which is fine if you will only ever be displaying a small, finite number of articles with no pagination.

If the desire is a complete solution that is trivial and easy for a noob to manage without too many rules, you'd probably be looking at forking the news module. Which requires more extensive knowledge of PHP, mysql and CMSMS.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
pWorker
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 31, 2016 1:30 pm

Re: Reorder Articles like Categories in Backend

Post by pWorker »

Hi Calguy,
thanks for your fast response.

So, once again I have to hammer smart!

My new idea, without learning module writing ;) but based on your priority value, is, that i create a protected-content page. On this page, login via FEU (only for the master user), i will paste a news summary template which shows the articles as sortable & serialized list elements (with jquery).

Code: Select all

 <li id="{$entry->fields.priority->value}"class="sortable">
here is a short piece i will review later, found in contex:

Code: Select all

$('.sortable').sortable({ 
    items: '> li.child',
    connectWith: $('tbody'),
    receive: function(event, ui) {
        var myOrder = new Array();
        $(".sortable li.child").each(function() {
            myOrder.push($(this).attr("id"));
        });
        console.log(myOrder.toString());  
    }
});
All articles will have a sort of hidden extra field, called->priority. So now, if master-user reorders the articles, the entry->priority values become the order id`s (+100 or so to prevent overwriting of other modules etc.). Now I could adapt your idea and paste on another page a {news}-tag which shows the articles sorted by their priority value... or not?

The advantage would be a light-weight backend functionality in front end.If im successfull with that, i will add top-articles checkboxes and so on too.

Could that be a valueable possibility?

Prevolution: I`m doing nearly the same vice versa with a you-tube-player. i push the id value, which is the embed code from a div-container-news-button {$entry->fields.EmbedLink->value}", to a div with specific id and there setting the src value to a string with that embedlink value, without reloading the page, so im very optimistic, that the priority values can be changed on the fly.


template

Code: Select all

<__script__>

$(function(){
  $('.video-meldungen').click(function () { 
  var id = $(this).attr("id");   
$("#frame").attr("src", "http://www.youtube.com/embed/"+ id +"?rel=0&autoplay=1");

    
$(".video-meldungen").removeClass("video-active");
  
    // adding classname 'video-active' 
    $(this).addClass("video-active");
});

});


</__script>

news-summary

Code: Select all

{foreach from=$items item=entry}

<a href="#top">

<div class="one-column video-meldungen" id="{$entry->fields.EmbedLink->value}">
<div class="video-preview-box">
    
                {if $entry->fields.Image->value}
		<img src="{$entry->file_location}/{$entry->fields.Image->value}" alt="{$entry->title|cms_escape:htmlall}">
		{else}
		<img src="{root_url}/uploads/images/dummy_video_prev.jpg" alt="{$entry->title|cms_escape:htmlall}">
		{/if}
		
</div>

<div class="video-meldungen-content">
<h3>{$entry->title}</h3>

</div>
</div>

</a>

{/foreach}
html

Code: Select all

<div id="youtube-box">
  
<__iframe id="frame" src="" width="600" height="363" seamless="seamless" frameBorder="0">
   </__iframe>

</div>


<div id="video-slider-nav">
<div class="flexslider-controls">
<ol class="flex-control-nav">
<li>
<h2>xxxx</h2>
</li>
<li>
<h2>xxx</h2>
</li>
<li>
<h2>xx</h2>
</li>
</ol>
</div>
</div>
<div id="video-meldungen-slider" class="flexslider">
<ul class="slides">
<li>{news detailtemplate="DummyNewsDetail" summarytemplate="NEWS-Meldungen-Videomediathek" category="Main-Banner | Main-Videomediathek | Reise & Tourismus"}</li>
<li>{news detailtemplate="DummyNewsDetail" summarytemplate="NEWS-Meldungen-Videomediathek" category="Main-Banner | Main-Videomediathek | Kunst & Kultur"}</li>
<li>{news detailtemplate="DummyNewsDetail" summarytemplate="NEWS-Meldungen-Videomediathek" category="Main-Banner*"}</li>
</ul>
</div>
</div>
Thanks in advance again.

...If you are bored of too less problems in your cmsms life, continue reading...


Thereafter I have to tag newsarticles with specific date information. The gamepoint here is, that i need user addable extra fields with front-end sortable date-input (a minor problem is, that a dropdown list element value can`t have a comma, so "Auto, Fahrrad und Co" has to be formatted elsewhere... ).
pWorker
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 31, 2016 1:30 pm

Add custom field -> dropdown -> FEU-List-User

Post by pWorker »

All changes in module_custom/news/templates/editarticle.tpl

Add extra-field named (e.g.) Autorenlabel -> type:dropdown

Add in template:

Code: Select all

 {if isset($custom_fields)}
        {foreach $custom_fields as $field}
        <div class="pageoverflow">
            <p class="pagetext">
                <label for="{$field->idattr}">{$field->prompt}:</label>
            </p>
            <p class="pageinput">
                {if $field->type == 'textbox'}
                    <input type="text" id="{$field->idattr}" name="{$field->nameattr}" value="{$field->value}" size="{$field->size}" maxlength="{$field->max_len}" />
                {elseif $field->type == 'checkbox'}
                    <input type="hidden" name="{$field->nameattr}" value="0" />
                    <input type="checkbox" id="{$field->idattr}" name="{$field->nameattr}" value="1"{if $field->value == 1} checked="checked"{/if} />
                {elseif $field->type == 'textarea'}
                    {cms_textarea id=$field->idattr name=$field->nameattr enablewysiwyg=1 value=$field->value maxlength=$field->max_len}
                {elseif $field->type == 'file'}
                    {if !empty($field->value)}{$field->value}<br />{/if} <input type="file" id="{$field->idattr}" name="{$field->nameattr}" />{if !empty($field->value)} {$delete_field_val} <input type="checkbox" name="{$field->delete}" value="delete" />{/if}
               
{* -------------------This is the important change------Custom-Content installed----------*}
{* ID of memberlist may be another also the name of your extra-field *} 


               {elseif $field->type == 'dropdown'}
                                          
             {if $field->prompt == 'Autorenlabel'}

             <select id="{$field->idattr}" name="{$field->nameattr}">
                                    
                       {html_options values=feu_smarty::get_group_memberlist(1) output=feu_smarty::get_group_memberlist(1) selected=$field->value}
              
             </select>
             
                {/if}
               {/if}  
                
            </p>
        </div>
        {/foreach}
        {/if}
Now you can use the selected "option" value as parameter, like:

Code: Select all

{$entry->fields.Autorenlabel->value}
Locked

Return to “Modules/Add-Ons”