1
Mazarin
Possible to write custom code in news post?
  • 2008/12/10 21:27

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


I've searched for an answer to my question, but haven't been able to find one. However, I do apologize if this has been asked before and then kindly ask you to please point out where I can find it.

I'm using the News 1.63 module and would like to be able to insert custom php code at the bottom of news posts. The reason behind my wish is that I'm running a site for a sports team, and for each news post in a specific category (game reports, but no other categories) I would like to display stats from the game in question from a db table.

Is this at all possible? If so, what would be the general, high-level approach to doing this? If not, are there any other options available to achieve the same results?

2
Mazarin
Re: Possible to write custom code in news post?
  • 2008/12/11 9:21

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


I thought about this a bit more this morning. Would a possible solution be to have a custom php block displayed in the news module, that retrieves a parameter (e.g. post ID) from the news post and based on that displays the relevant stats in the block? Is it even possible to retrieve such a parameter from a news post?

3
ghia
Re: Possible to write custom code in news post?
  • 2008/12/11 10:18

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You can add PHP code in the template news_item.html. You could call there a PHP file with as parameter $story.id that makes the table layout.

4
Mazarin
Re: Possible to write custom code in news post?
  • 2008/12/11 12:47

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


Oh, it's as simple as that. Thanks a lot for your help :)

5
Mazarin
Re: Possible to write custom code in news post?
  • 2008/12/12 21:24

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


It turned out it wasn't as simple as that. No matter how I try, I can't get the server to parse the embeded php in the html page news_item.html.

I've tried enabling it by putting a .htaccess file with "addtype application/x-httpd-php .html" in each and every directory from the one containing the file to the root web directory, without it having any effect on the news module. However, it works perfectly fine on custom html page in the root, i.e. it shouldn't be the server config file preventing the execution of the .htaccess.

Is there anything in the XOOPS folder/files that prevents the local .htaccess files override?

I've tried putting garbage in both the .htaccess files and the php code, so it seems something is preventing the override. Also, I have module cache turned off in the system settings.

Any ideas as to what could be the problem?

6
ghia
Re: Possible to write custom code in news post?
  • 2008/12/13 2:02

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Can you try this (using php) or this (including php)?

7
Mazarin
Re: Possible to write custom code in news post?
  • 2008/12/13 11:54

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


Both of them worked fine!

So it seems that for writing php in the html file, all that was needed was a different tag to specify the php code, i.e. <{php}>php code here<{/php}>. With this method, there was no need to create a .htaccess file.

Once again, thanks a lot for your help.

Login

Who's Online

172 user(s) are online (102 user(s) are browsing Support Forums)


Members: 0


Guests: 172


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits