Advertisement:

Author Topic: Show slug name and category id in admin area category section  (Read 610 times)

Resta

  • Sr. Member
  • ****
  • Posts: 345
Show slug name and category id in admin area category section
« on: September 22, 2018, 01:41:47 am »
Hello,

Is there a mod to show slug name in the category editing page in admin area - may be under advanced options?

Thanks!

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Show slug name and category id in admin area category section
« Reply #1 on: September 22, 2018, 02:01:31 am »
Hello,

Adding some JS could do it.
This code for now only adds ID's. It needs to be inserted in admin footer, don't know if there's a hook for it.

Code: [Select]
<script>
$(document).ready(function() {
    $('.category_div').each(function() {
        var id = $(this).attr('category_id');
        var name = $(this).find('.name');
        var name_str = name.text();
        var html = name_str+' <strong>ID: '+id+'</strong>';

        name.html(html);
    });
});
</script>

Regards.

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: Show slug name and category id in admin area category section
« Reply #2 on: September 22, 2018, 03:26:50 am »
:) Thanks, Patrick.

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: Show slug name and category id in admin area category section
« Reply #3 on: October 04, 2018, 01:14:05 pm »
Hi Patrik,

I tried similar for the Custom Field ID's but that does not work - any idea what is wrong?

Code: [Select]
<script>
$(document).ready(function() {
    $('.cfield-div').each(function() {
        var id = $(this).attr('field_id');
        var name = $(this).find('.name');
        var name_str = name.text();
        var html = name_str+' <strong>ID: '+id+'</strong>';

        name.html(html);
    });
});
</script>

Thanks!
« Last Edit: October 04, 2018, 01:19:29 pm by Resta »

m6mmi

  • Jr. Member
  • **
  • Posts: 72
Re: Show slug name and category id in admin area category section
« Reply #4 on: October 04, 2018, 07:28:03 pm »
Does anyone have any idea how to add this script with hook functions without modifying core file. Looks like a easy task, but I can´t get it working from external function which I added to theme functions.php file .. some code wizards here, who know how to do it?

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Show slug name and category id in admin area category section
« Reply #5 on: October 04, 2018, 09:28:05 pm »
Hi Patrik,

I tried similar for the Custom Field ID's but that does not work - any idea what is wrong?

Code: [Select]
<script>
$(document).ready(function() {
    $('.cfield-div').each(function() {
        var id = $(this).attr('field_id');
        var name = $(this).find('.name');
        var name_str = name.text();
        var html = name_str+' <strong>ID: '+id+'</strong>';

        name.html(html);
    });
});
</script>

Thanks!

Here's the fixed one, the problem was in the name class (.name-edit-cfield instead of .name):

Code: [Select]
<script>
$(document).ready(function() {
    $('.cfield-div').each(function() {
        var id = $(this).attr('field_id');
        var name = $(this).find('.name-edit-cfield');
        var name_str = name.text();
        var html = name_str+' <strong>ID: '+id+'</strong>';

        name.html(html);
    });
});
</script>

Does anyone have any idea how to add this script with hook functions without modifying core file. Looks like a easy task, but I can´t get it working from external function which I added to theme functions.php file .. some code wizards here, who know how to do it?

You can use this in your functions.php:

Code: [Select]
<?php
function cf_admin_category_ids() {
?>

<script>
// Your Javascript goes here...
$(document).ready(function() {
    $('.category_div').each(function() {
        var id = $(this).attr('category_id');
        var name = $(this).find('.name');
        var name_str = name.text();
        var html = name_str+' <strong>ID: '+id+'</strong>';

        name.html(html);
    });
});
</script>
<?php
}
osc_add_hook('admin_footer''cf_admin_category_ids');

Regards.

m6mmi

  • Jr. Member
  • **
  • Posts: 72
Re: Show slug name and category id in admin area category section
« Reply #6 on: October 05, 2018, 01:25:27 am »
Good man Patrick! Thank you for sharing the tip :) Works like a charm!

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: Show slug name and category id in admin area category section
« Reply #7 on: October 05, 2018, 07:32:29 am »
Quote
the problem was in the name class (.name-edit-cfield instead of .name)
Thought of trying that and I should have but after about several tries as it was getting late, I thought it would be better to ask one who knows better.

Thanks again!

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Show slug name and category id in admin area category section
« Reply #8 on: October 05, 2018, 10:54:45 am »
Quote
the problem was in the name class (.name-edit-cfield instead of .name)
Thought of trying that and I should have but after about several tries as it was getting late, I thought it would be better to ask one who knows better.

Thanks again!
Good man Patrick! Thank you for sharing the tip :) Works like a charm!

You're welcome. :)

Regards.