Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-11-17 17:28:21

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Wrap output twice

I’m trying to figure out how to modify a plugin so that it wraps some results within another set of HTML tags.

Currently, the code says:

$out = $out ? doWrap($out, $wraptag, $break, $class) : '';

As the results are mostly a list, I would like to then wrap an additional div around the entire results. This is mainly for styling purposes, as I’m using Bootstrap and want to use some of its alert styles.

So far, I have figure that two doWraps one after the other doesn’t work eg.

$out = $out ? doWrap($out, $wraptag, $break, $class) : '';
$out2 = $out ? doWrap($out, $outertag, $outerbreak, $outerclass) : '';

… where $outertag, $outerbreak and $outerclass are new attributes I have added to the tag.

I freely confess to just tinkering with the great work of others, and my PHP skills are pretty minimal. But I would like to get the HTML output to align with the needs of my CSS (whether Bootstrap or custom styles) and sometimes tinkering with the code is the only way.

Offline

#2 2014-11-17 20:25:32

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Wrap output twice

When you call doWrap($out, ...), $out must be an array, but the returned value is a string, so your second call to doWrap() fails. You could try to replace it with

$out2 = $out ? doWrap(array($out), $outertag, $outerbreak, $outerclass) : '';

Offline

#3 2014-11-17 20:47:58

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Wrap output twice

I did read the function for doWrap to try to understand what it did, and your explanation now helps me to make sense of it.

Thanks very much!

Offline

Board footer

Powered by FluxBB