PopUpNewsModule

It seems great minds think alike as I already had that code I was looking for the $variable to display the news item. Thanks

you can use the substr function from php

<?php echo substr($yourvariable, 0, 50); ?>

Will output the first 50, well actually 51 characters of your variable. you are telling it to start at character 0 and end at character 50. you can start and stop it where ever you would like. Hope this helps.

Hi Simpilot,

i found this website… http://php.net/manual/en/function.substr.php

but i cannot find out which variable i should use. I am not really into PHP, but learning. Could you give me a hint? :slight_smile:

I am trying to find the logic behind php but i am not getting it clear yet… my bad.

Thanks in advance,

Lucas

oh, by the way! Excellent module! KUDO’S!

Hi Simpilot,

i found this website… http://php.net/manual/en/function.substr.php

but i cannot find out which variable i should use. I am not really into PHP, but learning. Could you give me a hint? :slight_smile:

I am trying to find the logic behind php but i am not getting it clear yet… my bad.

Thanks in advance,

Lucas

oh, by the way! Excellent module! KUDO’S!

It will depend on what you are working on as to what to use for a variable.

In the popupnews module if you are trying to limit the characters of the subject line the data is presented in the template using the $subject variable. If you wanted to limit the subject to just say 10 characters you could do something like this in the template.

<?php echo substr($subject, 0 , 9).'...'; ?>

Which would give you something like:

Breaking N…

I follow the method you are using but im unable to find the correct variable to diplay the body of the news item in the popupnews_list, I can get the subject quite easily but not the main message itself. Any suggestions?

Just installed the news module, looks great, although, my news is displayed on this page of my site - http://euroscotva.co.uk/index.php/pages/news

so it doesnt appear on my main site, and when i click an item from the module i get presented with this -

http://euroscotva.co.uk/index.php/PopUpNews/popupnewsitem/?itemid=9

my main site - http://www.euroscotva.co.uk,

Hope you can help,

Connor

Just installed the news module, looks great, although, my news is displayed on this page of my site - http://euroscotva.co.uk/index.php/pages/news

so it doesnt appear on my main site, and when i click an item from the module i get presented with this -

http://euroscotva.co.uk/index.php/PopUpNews/popupnewsitem/?itemid=9

my main site - http://www.euroscotva.co.uk,

Hope you can help,

Connor

Post number 30 in this thread has the fix for your issue.

I get this error

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘PopUpNews::popupnewsitem’ was given in *********core/classes/MainController.class.php on line 218

I cant seem to figure it out..

(it happens when I click the link in the list box)

Sorry, didn’t see the updated version, I downloaded version 1.1 and now have it working good.

Thanks

Hi simpilot,

the code you mentioned at the top: <?php echo substr($yourvariable, 0, 50); ?> could you tell me where to put it and if any changes need to be made?

Thanks

Hi simpilot,

the code you mentioned at the top: <?php echo substr($yourvariable, 0, 50); ?> could you tell me where to put it and if any changes need to be made?

Thanks

It will depend on what you are working on as to what to use for a variable.

In the popupnews module if you are trying to limit the characters of the subject line the data is presented in the template using the $subject variable. If you wanted to limit the subject to just say 10 characters you could do something like this in the template.

<?php echo substr($subject, 0 , 9).'...'; ?>

ok got that…so “body” is a good variable? And this line is placed directly beneath the orginal call?

Thanks

I believe body is a good variable throughout the module. You would replace the “echo $body” verbage with the new code in order to limit the characters output to the display.

Hi Simpilot

I put the code <?php echo substr($subject, 0 , 99); ?> in my popupnews tpl file to no avail. I still can’t get the headline to show fully. Do you have any suggestions.

Thanks

I have a quick one too. I added the news module to my home page not in the side bar, but in the center. I would like to get rid of the posted on date and add the posted by author. I borrowed code from the news item tpl file and it didn’t work out so smooth.

Hi Simpilot

I put the code <?php echo substr($subject, 0 , 99); ?> in my popupnews tpl file to no avail. I still can’t get the headline to show fully. Do you have any suggestions.

Thanks

The title field is limited to 30 characters in the database. If your title is longer than that, anything past the 30 characters is not being saved in the database.

I have a quick one too. I added the news module to my home page not in the side bar, but in the center. I would like to get rid of the posted on date and add the posted by author. I borrowed code from the news item tpl file and it didn’t work out so smooth.

You will need to add a couple lines in the PopUpNews.php controller

after line 40 add;

Template::Set('subject', $row->subject);
Template::Set('postedby', $row->postedby);

then in the popupnews_list.tpl you will have $subject and $postedby available to you. The $posted by will only be the db id # for the poster that you will have to convert to a pilot number in the template.

1 Like

You will need to add a couple lines in the PopUpNews.php controller

after line 40 add;

Template::Set(‘subject’, $row->subject);
Template::Set(‘postedby’, $row->postedby);

then in the popupnews_list.tpl you will have $subject and $postedby available to you. The $posted by will only be the db id # for the poster that you will have to convert to a pilot number in the template.

Thank you very much! I really appreciate it. +1 for you.

**EDIT**

Worked like a charm. Thanks again!

The title field is limited to 30 characters in the database. If your title is longer than that, anything past the 30 characters is not being saved in the database.

is there any way to change the character limit?

You can use phpMyAdmin or the command line to change the size limit of the field in your database.

1 Like

You can use phpMyAdmin or the command line to change the size limit of the field in your database.

Worked great. Thanks Simpilot

Simpilot Great Module! Sorry I don’t know how do you edit or add news and what files do you need to edit? Thank You Very Much!!!