1
anselmoso
How can I access all blocks from within my theme?
  • 2006/10/15 13:10

  • anselmoso

  • Just popping in

  • Posts: 3

  • Since: 2006/10/15


Hi,

We're running XOOPS 2.2.3 on our community website and I'm doing a "theme hack" right now....

My question is:

How can I access all system-wide configured blocks from within my theme?

I mean, normally we all do it like this:

<{foreach item=block from=$xoops_lblocks}>
......
<{/foreach}>

to access the blocks, which are configured for the currently active page on the left.

The problem is the restriction, that I can only access the blocks, which are configured for the page, that is active at the moment.
For example: If the admin configures, that "who's online" is only viewable on the forum pages, I can't access this block if I'm leaving the forum-area on our site.


Let me explain what I want to do, so that you guys understand what I mean:

The standard design of our community is configured so that some blocks only appear on specific pages. What I want to do is a theme, where some specific blocks are available on the whole(!) site (so that they appear, whatever page you are looking at right now). So what I'm planing is kind of "blasphemy", because I want to configure these blocks statically. 3 or 4 blocks shall be configured statically in the theme so that they always appear on the left / right.


I hope you can follow my plan:)


In "spoken syntax", I want to do something like this:


.....
....(configure some variables to "collect" the specific blocks).....
........
$whosOnlineBlock, $searchBlock, $someOtherBlock;

<{foreach item=block from=$xoops_all_blocks}>
if $block.title = 'Who's Online' --> $whosOnlineBlock = $block;
........
.......(collect all blocks)....
........
<{/foreach}>



and then include these blocks on the left / right later on.


Maybe you could also help me out with the syntax...maybe I should do this in normal PHP syntax?



Thanks in advance, anselmoso

2
Quest
Re: How can I access all blocks from within my theme?
  • 2006/10/15 13:44

  • Quest

  • Friend of XOOPS

  • Posts: 1034

  • Since: 2005/11/19


Woah, that makes my head dizzy. I do understand what you want to do but embedding them into the theme is a lot work and should you decide to change it later, more work. Then again maybe it isn't. Have you considered cloning the blocks you would like to use, renaming them for easy identification to your desire, then setting those blocks to appear on the pages/modules you want them to appear on as a consistant basis? Here is a link on how to clone a block:

Cloning a Block

Hth,
Quest

3
anselmoso
Re: How can I access all blocks from within my theme?
  • 2006/10/15 14:09

  • anselmoso

  • Just popping in

  • Posts: 3

  • Since: 2006/10/15


Hey Quest,

First: thanks for your quick answer!

Quote:
I do understand what you want to do but embedding them into the theme is a lot work and should you decide to change it later, more work.


work and time aren't the problem in my (very special) case;) The administrators of our page don't want to change the standard theme, but me and a lot of other users want this "alternative look". The standard design also hasn't any right blocks configured and we want a "look with left and right blocks", right now the theme only includes blocks on the left.

So, I will do anything to get "our old look back" - and the administrators only give me the "allowance" to do an alternative theme. In this theme, I can do "what I want" - but I can't change any system wide block settings or anything else.


I don't know if this "block cloning" is the right way to go....? If I understand this cloning right, the cloned block would also appear in the XOOPS blocks administration? If that's the case, this way is a "no go" :) This would lead to "stress with the admins"

I also thought about copying the block code into external php files and then including them in my theme at the desired position, but as far as my knowledge goes, this won't work, either...

So - do you still think this "cloning" is the way to go, then? As I said - the admins should "be bothered as less as possible" from my theme. I can "do what I want in my theme", but as soon, as I "change to much in the system wide config", the guys go mad;)

4
anselmoso
Re: How can I access all blocks from within my theme?
  • 2006/10/21 22:24

  • anselmoso

  • Just popping in

  • Posts: 3

  • Since: 2006/10/15


Does anybody have another idea?

5
abrizan
Re: How can I access all blocks from within my theme?
  • 2007/1/21 12:58

  • abrizan

  • Just popping in

  • Posts: 82

  • Since: 2005/11/14


I also want help on this.

6
nachenko
Re: How can I access all blocks from within my theme?
  • 2007/4/26 10:17

  • nachenko

  • Quite a regular

  • Posts: 356

  • Since: 2005/1/18


Umm...

Go to the module folder of the block you want to call.

Open xoops_version.php, locate a part of the array making references to blocks, like this:

Quote:

$modversion['blocks'][1]['file'] = "wfs_artmenu.php";
$modversion['blocks'][1]['name'] = _MI_WFS_BNAME_ARTMENU;
$modversion['blocks'][1]['description'] = "Shows Article menu";
$modversion['blocks'][1]['show_func'] = "b_wfs_artmenu";
$modversion['blocks'][1]['template'] = $wfsTemplates['artmenublock'];


Here you have the file and the function.
So, in the theme, include this snippet:

Quote:

<{php}>
include (XOOPS_ROOT_PATH/modules/etc etc the file that contains the block code);
$result = function that calls the block, should return some kind of array/object;

....
now, php code here to insert the stuff you got into the theme

<{/php}>


A bit messy, but it works. Just look here:

http://www.marruecosdigital.net/xoops/modules/mylinks/

The horizontal submenus are inserted into the theme.

7
iHackCode
Re: How can I access all blocks from within my theme?

CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

Login

Who's Online

230 user(s) are online (148 user(s) are browsing Support Forums)


Members: 0


Guests: 230


more...

Donat-O-Meter

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

Latest GitHub Commits