Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
News Manager Addons plugin
(2018-10-01, 02:37:17)Carlos Wrote: I've not tested, but I think it should work:

- In your NM Addons template code, change:
Code:
<li style=...>
to:
Code:
<li id="nma_post_{{post_slug}}" style=...>

- Insert this in the <head> section of your template:
Code:
<?php if (nm_is_single()) { ?>
<style>
#nma_post_<?php nm_post_slug(); ?> { display:none; }
</style>
<?php } ?>

It works great, thank you very much!

I had almost the same idea but I just did not know where to put the if-clause...

Smile
Reply
Hey Guys
i'm quite new to Get Simple and want to use the NewsManager Plugin as an Event List where the Events are listed by Date (and dates in the future are also listed) and when the date is over they disappear from that list.
Is that possible with News Manager Addons?
Thanks for your help
Scorpio
Reply
Yes, it's possible. Precissely I intended to suggest this to you in the NM thread.

You can use functions nm_custom_list_future or nm_custom_display_future in your template or components.

If you need any further information or help let me know.
Reply
You made my day. Thank you so much!
Reply
I found an easier way to display only posts with a date in the future instead of filtering the other ones out (as with nm_custom_display_future). I edited line 25 in functions.php in /plugins/news-manager/inc/ and i just turned the < sign into the > sign.
With the method you suggested it displays only the first post that is in the future but with the method i just described it displays all future posts.

I have just one problem. With my method as it works now, the entries are in the wrong order. So, an entry with the date 2019-01-05 is at the top and an entry with the date 2018-12-28 is below it while it should be the other way round.
Can anyone help?
Reply
Don't know why you only get one post in the future.
Anyway, you can set the number of posts to be displayed.

An example:
- create a page Events
- write some future posts with tag 'events'
- in your template, insert this after <?php get_page_content(); ?> :
Code:
<?php
if (return_page_slug()=='events') {
  nm_set_custom_maxposts(9999);
  nm_custom_display_future('
    <h3><a href="{{post_link}}">{{post_title}}</a></h3>
    <p>{{post_date}}</p>
    {{post_content}}
    ', 'events');
}
?>
demo: http://webs.org.es/newsmanagerdemo/events/

(past events are here: http://webs.org.es/newsmanagerdemo/news/tag/events )
Reply
Thanks, that works pretty fine.
Reply
Dear GS-friends,

thanks to some examples from Oleg I figured out how to display news in custom layout with php code directly.

Example:

Code:
<div class="posts">                
<?php nm_set_custom_image(160,160,1); ?>
<?php nm_set_custom_excerpt(200); ?>
<?php nm_set_custom_maxposts(8); ?>  
<?php nm_custom_display_random('  
<article>
<h4><a href="{{ post_link }}">{{ post_title }}</a></h4>
<p class="nm_post_date">{{ post_date }}</p>
<a href="{{ post_link }}">{{ post_image }}</a>
<div class="my_excerpt">{{ post_excerpt }}</div>
</article>
'); ?>
   </div>


For a newer project I urgently need to output the "Tags" of the news entries, too.
(The goal is to add the "Tag" as a CSS-Class to the entries in order to enable a simple filtering function with javascript and CSS)

I tried {{ post_tag }} , but it didn't seem to work.

Is there any way to output the News-"Tags" with php?


Thanks for all your great coding and help!
Reply
I'll add support for that to the plugin.
Reply
Try this 0.9.6 beta version
http://www.cyberiada.org/cnb/data/upload...6-beta.zip

You can use the {{ post_tags }} placeholder to display the post tags.
Reply
EXCELLENT!!!! Great thanks!!!!

A little complementary suggestion: Is it possible to wrap a "div" or "span" around the seperate tag-items?

(In order to style the items via CSS child-selector if needed, as coloured inline-blocks or whatever ...)


Best regards,
Holger
Reply
OK, the last quesion was silly - in order to use "tags" as CSS-class they have to be in lowercase sparated by " ", with nothing wrapped around it.


Nevertheless I tried a quick and dirty solution for the <span> output (line 220):
PHP Code:
     if ($showtags) {
 
       $tags strip_decode($post->tags);
 
       if (!empty($tags)) {
 
         if (function_exists('nm_lowercase_tags')) // NM 3.0+
 
               $tags nm_lowercase_tags($tags);
         
 $tags explode(","$tags);
         
 $tags "<span>".implode('</span><span>'$tags)."</span>";
 
       }

        
$str str_replace('{{ post_tags }}', ($tags), $str);
 
     } ... 


By the way: Maybe there's an issue with "$tagseparator" (I assume this shall be included in (original) line 225)

I've set an individual separator in "News Manager Settings", this is visible in the standard news-manager output but not in the custom output.


Best regards!
Reply
(Replying to http://get-simple.info/forums/showthread...4#pid64234 )

(2019-05-10, 02:23:50)smdp-1971 Wrote: If I do not select an image when creating new news - is there a way to set the default image, but only in the sidebar

I think I still haven't documented this...

You can use NM Addons' function nm_set_custom_image (with optional paramers for width, height, cropping and default image).

Example:
Code:
<?php nm_set_custom_image(200, 150, 1, 'image1.jpg'); ?>
(the default image is relative to data/uploads, but you can also specify a full url like http://...)

But if you just want to set the default image and not specify width, etc.:
Code:
<?php nm_set_custom_image(null, null, null, 'image2.jpg'); ?>

You have to insert that code before <?php nm_custom_display_recent ... ?>
Reply
(2013-06-25, 06:44:41)Carlos Wrote: It's a temporary thing (that's why I've added to this complementary plugin, not to NM itself) that Connie and others need.

I may add the functionality to existing nm_list_recent (that doesn't have parameters, so I can make use of this while keeping backwards compatibility), like:

nm_list_recent($tag='', $max=0) // $max = number of posts; 0 = use value in settings

As for combination of tags, I had thought about this, but as noone has ever asked for this I intended to leave this for the future. It could be comma-separated tags in the 1st parameter (for OR, and another separator for AND... still haven't thought about this)

Hello Carlos, 
I know this is an old question but I am searching now a solution to make combination of tags with AND.
Could you provide me some help about this ? 

Thanks in advance, 

Pablito
Reply
@Pablito

Try this "0.9.6 beta 2" version:
http://www.cyberiada.org/cnb/data/upload...-beta2.zip

Instead of specifying just one tag to filter by, you can now put several ones separated by ampersands, e.g. 'web&css&development'

BTW this version also has support a new {{post_metad}} placeholder (that Alexander_ requested some time ago)
Reply
(2020-05-10, 06:27:46)Carlos Wrote: @Pablito

Try this "0.9.6 beta 2" version:
http://www.cyberiada.org/cnb/data/upload...-beta2.zip

Instead of specifying just one tag to filter by, you can now put several ones separated by ampersands, e.g. 'web&css&development'

BTW this version also has support a new {{post_metad}} placeholder (that Alexander_ requested some time ago)

Hello Carlos, 
thanks for adding this functionality !
I tried it this morning and it works nice !
The new {{ post_tags }} is also perfect for my use !

Thanks a lot ! Really appreciate.

By any chance, do you have any experience concerning big loads of data ? 
I want to set up a site with 10 000 posts and maybe 500 categories. 
Do you think it could be done with News Manager ? 
There will be some double crossing on tags for this site.

I will try to generate these pages with tags to make a test and see if it works with a nice speed.
Reply
(2020-05-10, 17:22:52)pablito Wrote: By any chance, do you have any experience concerning big loads of data ? 
I want to set up a site with 10 000 posts and maybe 500 categories. 
Do you think it could be done with News Manager ? 
There will be some double crossing on tags for this site.

I will try to generate these pages with tags to make a test and see if it works with a nice speed.

In principle it can be done, but I suppose it depends on the server.

Some time ago I posted a very simple script to automatically generate many posts, so that you can do your own tests:
http://get-simple.info/forums/showthread...5#pid68725
Reply
(2020-05-10, 18:48:48)Carlos Wrote:
(2020-05-10, 17:22:52)pablito Wrote: By any chance, do you have any experience concerning big loads of data ? 
I want to set up a site with 10 000 posts and maybe 500 categories. 
Do you think it could be done with News Manager ? 
There will be some double crossing on tags for this site.

I will try to generate these pages with tags to make a test and see if it works with a nice speed.

In principle it can be done, but I suppose it depends on the server.

Some time ago I posted a very simple script to automatically generate many posts, so that you can do your own tests:
http://get-simple.info/forums/showthread...5#pid68725

I generated 10 000 posts with this script (each post has a descriptive tag + country tag + region tag + city tag), so 4 tags for each post. 

<?php

echo "generate<br>";

//easy to set a post as private

$max = 10000;
$tagcitymax = 20;
$tagregionmax = 100;
$tagstatemax = 500;
$othertags = 10;

$outputdir = "work/";
$lorem = "Habitasse platea dictumst vestibulum rhoncus est pellentesque elit. Semper quis lectus nulla at volutpat diam. Tristique senectus et netus et. Volutpat maecenas volutpat blandit aliquam etiam erat velit scelerisque. Amet consectetur adipiscing elit ut. Velit egestas dui id ornare arcu odio ut sem nulla. Erat imperdiet sed euismod nisi porta lorem mollis aliquam ut. Id diam maecenas ultricies mi eget mauris pharetra. Sagittis aliquam malesuada bibendum arcu vitae elementum. Viverra nam libero justo laoreet sit. Mus mauris vitae ultricies leo. Ac odio tempor orci dapibus ultrices. Elementum facilisis leo vel fringilla est ullamcorper eget. Justo laoreet sit amet cursus. Sagittis nisl rhoncus mattis rhoncus urna neque. Aliquet enim tortor at auctor urna nunc id. A iaculis at erat pellentesque adipiscing commodo elit.";
$image = "http://127.0.0.1/getsimple-test/data/uploads/test.jpg";

for ($i=1;$i<=$max;$i++) {

$outputfile = $outputdir . $i . ".xml";
echo $outputfile."<br>";

$tagcity = "city" . strval((int)(($i-1)/$tagcitymax) + 1);
$tagregion = "region" . strval((int)(($i-1)/$tagregionmax) + 1);
$tagstate = "state" . strval((int)(($i-1)/$tagstatemax) + 1);
$othertag = "tag" . strval($i%$othertags);

echo $tagcity."<br>";
echo $tagregion."<br>";
echo $tagstate."<br>";
echo $othertag."<br>";

$tags = "$othertag,$tagcity,$tagregion,$tagstate";

$fp0 = fopen($outputfile,"w+");

fwrite($fp0,utf8_encode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"));
fwrite($fp0,utf8_encode("<item><title><![CDATA[".$i."]]></title><date><![CDATA[Sun, 10 May 2020 10:00:00 +0200]]></date><tags><![CDATA[".$tags."]]></tags><private><![CDATA[]]></private><metad><![CDATA[]]></metad><image><![CDATA[".$image."]]></image><content><![CDATA[&lt;p&gt;".$lorem."&lt;/p&gt;\n"));
fwrite($fp0,utf8_encode("]]></content></item>"));
fclose($fp0);
}

?>

I tried on my local installation and it is surprisingly going fine ! 
I can modify the file after in the editor (I have 667 pages with 15 posts each).

When I try to look at tags and even search combinations of 2 tags, it works well ! 
The same installation in a wordpress would be a nighmare I think  !

I need to try on a hosting service + add the related posts stuff too for testing.
Reply
Rainbow 
Is there any way to sort the posts in alphabetical order instead of by date?

I've tried so many things but no luck.
Thank you very much in advance!
Reply
Idea PARTIAL SOLUTION:
News posts show up alphabetically a-z, instead of by date new-old.

I used some code from Carlos' alphabetical tag sorting.

In: news_manager > inc > function.php

Replace : ---------------------------------------------------------------------------

foreach ($data->item as $item) {
if ($all || $item->private != 'Y' && strtotime($item->date) < $now)
$posts[] = $item;
}
return $posts;
}

with: ------------------------------------------------------------------------------

foreach ($data->item as $item) {
if ($all || $item->private != 'Y' && strtotime($item->date) < $now)
$posts[] = $item;
}

// START Post Title Alphabetical Sorting
function nm_alphabeticPostTitles($a, $b) {
if (function_exists('mb_strtolower'))
return (mb_strtolower($a->title) < mb_strtolower($b->title)) ? -1 : 1;
else
return (strtolower($a->title) < strtolower($b->title)) ? -1 : 1;
}
usort($posts, 'nm_alphabeticPostTitles');
// END Post Title Alphabetical Sorting

return $posts;
}

-----------------------------------------------------------------------------------
BTW, it works in the NM clones as well. Just replace all instances of nm_ with nmclone*
Reply
I'm looking for a way to display one (and only one) post with a specific URL. Is there a function like nm_custom_display_recent($template,$url)?

Or any other ideas?

Alex
Reply
(2020-10-24, 02:55:32)Alexander_ Wrote: I'm looking for a way to display one (and only one) post with a specific URL. Is there a function like nm_custom_display_recent($template,$url)?

Or any other ideas?

Alex

You could give it a tag. then
PHP Code:
nm_list_recent_by_tag('tagname'1

[edit]
doh, no. nm_custom_display_recent('tagname') or similar
Reply
Quote: nm_custom_display_recent('tagname')

That's the way I've done it. But I don't like to see all these "single tags" in the tag list in the sidebar. Therefore I'm looking for another solution.
Reply
You can use a "hidden tag" - just prefix it with an underscore, e.g. _tagname
That tag will not be displayed anywhere.
Reply
(2015-04-22, 07:47:31)morvy Wrote: thanks for pointing me to right direction, if anybody needs similar posts by tag, here's my code

Code:
$num_post = 5;
$slugs = array();
$url = nm_get_url('post');
$posts = nm_get_tags();
foreach($posts as $tag => $post) {
    if(nm_post_has_tag($tag)) {
        foreach ($post as $slug) {
            $slugs[] = (string)$slug;
        }
    }
}
$slugs = array_unique($slugs);
if(($key = array_search(nm_post_slug(false), $slugs)) !== false) {
    unset($slugs[$key]);
}
shuffle($slugs);
$slugs = array_slice($slugs, 0, $num_post);
$all = nm_get_posts();

echo '<ul class="nm_similar_post">';
foreach ($all as $post) {
    if(in_array($post->slug, $slugs)) {
        echo '<li><a href="'.$url.$post->slug.'" title="'.$post->title.'">'.$post->title.'</a></li>', PHP_EOL;
    }
}
echo '</ul>';

I was wondering if there is a way to also implement the image with the post on this code...
I tried to modify it, but I only got the clickable image path underneath the title.

Thank you!
Reply




Users browsing this thread: 4 Guest(s)