1
hardyvoje
Embedding PHP code in theme template?
  • 2007/4/25 21:36

  • hardyvoje

  • Not too shy to talk

  • Posts: 123

  • Since: 2005/12/25


Hello!

What is the easiest way to implement PHP snippet into template / theme?

I need to put PHP code to display footer information in bottom of page (data will be delivered via database).

Is there something like [php]mycode[/php]

?
FreeResources Design Portal: http://www.omnetwork.net | Open Source Gaming Portal: http://www.osgamer.org

2
BlueStocking
Re: Embedding PHP code in theme template?

by hardyvoje on 2007/4/25 16:36:17
__________________

There is a php selection... for the blocks

Resized Image

Good Luck
BlueStocking
https://xoops.org/modules/repository .. It is time to get involved - XOOPS.ORG

3
BlueStocking
Re: Embedding PHP code in theme template?

Along the same lines I have another programing related question:

I want to make another menu item on the main menu -- without having to install a block to do it.

ADMIN MAIN MENU EDIT TEMPLATE 

<table cellspacing="0">
  <
tr>
    <
td id="mainmenu">
      <
class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}></a
[
color=990000]<a href="http://upnrunnin.hypermart.net/index.html">page 2</a>
      [/
color]<!-- start module menu loop -->
      <{foreach 
item=module from=$block.modules}>
      <
class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a>
        <{foreach 
item=sublink from=$module.sublinks}>
          <
class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a>
        <{/foreach}>
      <{/foreach}>
      <!-- 
end module menu loop -->
    </
td>
  </
tr>
</
table>

***********************************************

I have inserted the Link to desired page using html... but it doesn't display in the menu area -- I haven't figured out why


It is satisfactory in block view.
http://upnrunnin.hypermart.net/xoops01/

EDIT ADDON:
THIS WORKED.... I missed it HAD TO BE A CLONE TEMPLATE.
________________________

1. You need to create a template set to work on(you can not work on 'default' template set). If you done that, igore the rest of this point. So go to admin part of XOOPS and System admin -> Templates. Then chose "clone", enter the name of new template set and click "Submit".

Next you need to tell XOOPS to use this template set. So go to System Admin -> Preferences -> General Setings and for "Default template set" option chose the new template set you created, scroll down and click "Go!"

2. Now you need to edit the template for main menu: Go to System Admin -> Templates and from the section of the new template click on list next to System (System [List (27)]). Find "system_block_mainmenu.html" and click edit. You should see something like this: The EXAMPLE ABOVE.
https://xoops.org/modules/repository .. It is time to get involved - XOOPS.ORG

4
Sophie2
Re: Embedding PHP code in theme template?
  • 2007/4/25 22:23

  • Sophie2

  • Just popping in

  • Posts: 81

  • Since: 2005/11/21


Quote:
Is there something like [php]mycode[/php]?


<{php}>
include('yourcode.php');
<{/php}>

5
nachenko
Re: Embedding PHP code in theme template?
  • 2007/4/25 22:24

  • nachenko

  • Quite a regular

  • Posts: 356

  • Since: 2005/1/18


PHP inside Smarty:

<{php}>
...
<{/php}>
Use it on a theme file or block template, whatever you need.

Also, there are PHP custom blocks


For the last question, just capture the module name and insert the code. Suppose you want to insert a link in main menu after a module called "my pictures":

Quote:

<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a>

<{if $module.name == "my pictures" }>
... insert your link here ...
<{/if}>

foreach loop for submenus here .........
<{/foreach}>
<!-- end module menu loop -->


The link will appear right after the link to "my pictures". Remember to add class "menuMain" to the link, just like in your own code (you forgot to do it in your example code):

Quote:
...
<a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/">...

6
BlueStocking
Re: Embedding PHP code in theme template?

by nachenko on 2007/4/25 17:24:16
Thank you much....

Will do it now, hopefully with better results.
Didn't forget... just didn't know. (still don't)
that will be my next ???

(Once I apply it then the next time I will know.)
Again, thanks...

BlueStocking
https://xoops.org/modules/repository .. It is time to get involved - XOOPS.ORG

7
BlueStocking
Re: Embedding PHP code in theme template?

The WHY it did not work for me, was because I was using the "default" template. YOU/I MUST use a different cloned template. In my case I named a cloned template "defaultclone"
and edited that from the
ADMIN/ BLOCKS/ MAIN MENU/ | Template Set Manager >> defaultclone >> Edit template file.

Thank you all....
BlueStocking
https://xoops.org/modules/repository .. It is time to get involved - XOOPS.ORG

Login

Who's Online

61 user(s) are online (32 user(s) are browsing Support Forums)


Members: 0


Guests: 61


more...

Donat-O-Meter

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

Latest GitHub Commits