1
Catzwolf
Position a block anywhere you want hack................
  • 2008/4/20 6:48

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Yup, you read that right

Here is a little smarty hack to place a chosen block anywhere within a template using a smarty variable.

Normally placements with blocks in XOOPS are very rigid and for the most parts you are confined to the three column system etc. This smarty hack is an attempt to get away from this structure and to use a less rigid approach to block placement. Basically, I will place a chosen block where I want it and not forced into an area that doesn't work for me.

So now you should be able to place a block , just about anywhere you want within your theme.

It works by accessing a smarty function and pulling the information from the database and displaying the block in the chosen area of your theme.

The hack respects the block configurations and settings. So it will show only on the module page/s selected and only to the groups you have given permissions to view. ( Hopefully )

You can download this script from this location!

Please read the readme.txt for installation and usage.

Note: This is just the first version and there maybe some issues that I have not foreseen. So please report back to me any problems, bugs, security issues or features you may like to see within this hack.

Drawback of this:

At the moment the biggest draw back is that the SQL queries will go up the more of these blocks you add onto your site. Yes, it does uses 'Xoops Caching' but that doesn't respect the main issue of getting the block information. I hope to address this fully in another release.

ATB

Catz

2
mjoel
Re: Position a block anywhere you want hack................
  • 2008/4/20 10:09

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


thank you catzwolf...i think this should be shipped with core

all this while i use the method by hervet
http://xoops.instant-zero.com/modules/news/article.php?storyid=20&keywords=block

3
Mamba
Re: Position a block anywhere you want hack................
  • 2008/4/20 10:56

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


catzwolf, that's very innovative!!!!

I hope, I'll find some time soon to test it.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

4
Catzwolf
Re: Position a block anywhere you want hack................
  • 2008/4/20 17:59

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Thanks guys,

Hope it helps a little :)

5
trabis
Re: Position a block anywhere you want hack................
  • 2008/4/20 21:18

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Thanks catzwolf_ !

Another alternative is using conditions inside the theme:

Use this where the block would display:
Quote:

<{foreach item=block from=$xoops_lblocks}>
<{if $block.title == "my block title"}>
<{$block.content}>
<{/if}>
<{/foreach}>


And then change the left column code:
Quote:

<{if $xoops_showlblock == 1}>


<{foreach item=block from=$xoops_lblocks}>
<{if $block.title != "my block title"}>
<{include file="$xoops_theme/theme_blockleft.html"}>
<{/if}>
<{/foreach}>


<{/if}>


In the block admin I would use set "my block title" to display in the left column.

6
orgunozcu
Re: Position a block anywhere you want hack................
  • 2008/6/13 18:37

  • orgunozcu

  • Not too shy to talk

  • Posts: 136

  • Since: 2005/9/1 5


i tried this hack but it doesnt work.. can you exaplain again pls.

7
geronimo_nd
Re: Position a block anywhere you want hack................

where can wee find it beacose the link above is not working


8
jimmyx
Re: Position a block anywhere you want hack................
  • 2010/9/3 3:30

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


the post is outdated

if you are using 2.4

try defacer for block anywhere

http://www.xuups.com/modules/publisher/visit.php?fileid=14


rember to read the readme..there is a guide on how to use the block anywhere hack
Quote:

What is Defacer Module (v1.0 Final) ?
======================

With this Xoops module, your can:
- change themes, metadata and permissions for any given page.
- enable jgrowl redirection system (xoops 2.4 only)
- use blocks anywhere (xoops 2.4 only)



Requirements
====================

Works in 2.4.x, xoops 2.3.x, xoops 2.2.x, xoops 2.0.18 & up, ????? 1.x

Others cms versions were not tested.

Php5 only




How to install Defacer
====================

Copy defacer folder into the /modules directory of your website.
Then log in to your site as administrator, go to System Admin > Modules, look for the defacer
icon in the list of uninstalled modules and click in the install icon.
Follow the directions in the screen.


ATENTION, if you are NOT using xoops 2.4 or ????? 1.1
you have to add a line in header.php and footer.php at the root of your instalation

In yoursite/header.php paste the line

@include_once XOOPS_ROOT_PATH . '/modules/defacer/include/beforeheader.php';

right after

defined("XOOPS_ROOT_PATH") or die( 'XOOPS root path not defined' );

In yoursite/footer.php paste the line

@include_once XOOPS_ROOT_PATH . '/modules/defacer/include/beforefooter.php';

right after

if (!defined("XOOPS_ROOT_PATH")) {
die("XOOPS root path not defined");
}




Tips
=======
When creating pages you can use '*' symbol in the url field to match any url.

You should use relative paths
If you select news module your path will be related to yoursite/module/news/
You should add for example
index.php and not modules/news/index.php

System module is relative to root
You can select system module and enter this url to cover all userinfo pages:
userinfo.php*

Tips for blocks anywhere (xoops 2.4 only)
=========
Just prefix your block title with an underscore and you will be able to use it
has a smarty variable inside your theme or template
Example:
-Edit User menu block and rename it to _User Menu
-Take notice of the "bid" in the url, in this case it is '1':
modules/system/admin.php?fct=blocksadmin&op=edit&bid=1
-Usage on theme/template:
<{$xoops_block_1.title}> --> echos User Menu
<{$xoops_block_1.content}> --> echos the block content


Limitations
========

The block for changing themes is deactivated when using Defacer Theme Changer.



Feedback
========

Please use http://www.xuups.com (xoops user utilities)


9
blackrx
Re: Position a block anywhere you want hack................
  • 2013/4/26 1:21

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


Quote:

mjoel wrote:
thank you catzwolf...i think this should be shipped with core

all this while i use the method by hervet
http://xoops.instant-zero.com/modules/news/article.php?storyid=20&keywords=block



the website is no longer available but i managed to backup it from archive.org


i like this method because we can use it in php block...where trabis defacer anywhere block can only be use in theme.html or smarty template

----------------------------------------------------------------------

How to display a dynamic content in yoaur theme (outside Xoops blocks) ? - Xoops Tips - News
Xoops Tips : How to display a dynamic content in yoaur theme (outside Xoops blocks) ?
Posted by Herve on 2007/8/25 19:39:06 (383 reads) News by the same author

In a previous article, I was talking to you of the release of one of my modules, Boox, with which you can manage static content which is not approachable by Xoops.

The module is very useful but for this moment you can't manage dynamic content.

It could be useful if you could put in your site's theme, the content from any Xoops module.

I'm showing you a solution on which I have worked.


Before all, please don't ask me how to do it for any other Xoops module, search by yourself, it's more interesting
and it's not hard

A customer for which I am working, wanted to display partners (from the Xoops Smartpartner module) inside the header of his site.

This header does not contains Xoops blocks and this last can't display blocks to this place.


After I had imagine many solutions, I have decided to keep the partners modules so that my customer works in a user interface he used to see.

So, partners are created and managed from the Xoops backoffice, inside the SmartPartner module, but it's another solution which will display partners.

In fact, I'm going to bringback the module's block content !

1/ First, set the block's parameters from the Xoops blocks manager as if you wanted to use it "normally".

For this moment, set the block as visible (we will deactivate it later). In my case, I have set and display the block so show partners.


2/ Once you have done it, go in you database with, for example, PhpMyadmin,
and look at the content of the xoops_newblocks (replace xoops with the prefix you used during your website's installation)

Search for the visibles blocks, you can do it simply with a such query :
SELECT * FROM `xoops_newblocks` WHERE `visible` = 1

Then locate (with its name), the block you made visible in the point 1 and copy somewhere
the content of the field options, in my case it was :
1|0|1|1|id|DESC|1

Copy also the content of the following fields (I have wrote their name and their content) :

dirname : smartpartner
func_file : partners_list.php
show_func : b_partners_list_show
template : partners_block_list.html

3/ Go back in the Xoops blocs manager and hide the block you activated in the point 1

4/ Edit your theme (the file theme.html) and write this where you want to see the block's content :
Quote:


<{php}>
include XOOPS_ROOT_PATH.'/mainfile.php';
include_once XOOPS_ROOT_PATH.'/class/template.php';
include_once(XOOPS_ROOT_PATH.'/modules/smartpartner/blocks/partners_list.php');
$result = b_partners_list_show(explode('|','1|0|1|1|id|DESC|1'));
$tpl = new XoopsTpl();
$tpl->assign('block', $result);
$tpl->display('db:partners_block_list.html');
<{/php}>

The red parts must be replaced with the informations you get in the point 2

Don't forget to update your site (and may be to remove the content of the templates_c folder).

That's all !

---------------------------------------------------------------------------



10
irmtfan
Re: Position a block anywhere you want hack................
  • 2013/4/26 3:34

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


@blackrx:
this topic is very old.
besides the block anywhere hack was implemented in the core 2.5.5 so you can use it with the core.

Login

Who's Online

260 user(s) are online (154 user(s) are browsing Support Forums)


Members: 0


Guests: 260


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