Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-04-14 14:50:44

SuperMAG
Member
Registered: 2010-04-04
Posts: 35

Need a bit of help making a wordpress plugin work with textpattern

Its called Tabs and Sides, it is originally converted from joomla http://www.joomlaworks.gr/content/view/15/42/ .

This plugin was one of most important plugins in my site before i converted from wordpress. now i am trying to convert it textpattern.

I am trying to make it work with texpattern.

When you make a tab, its should be written like this:

{tab=HERETITLE}

Content here

{tab=ANOTHERTAB}

Content here

{/tabs}

{slide=Here is the slide title}
Content here
{/side}

This whole process is connected with just one php file, just donno how to convert that file to make it a plugin that works with textpattern, i can add script, css myself, just donno how to make texpattern convert the {tab} thing.

Would really appreciate anyone help me with this, it can be very useful to other people too. here that php file.

<?php

/*

Plugin Name: WP Tabs And Slides

Plugin URI: http://www.artonesia.org/

Description: WP-TabsAndSlides is plugin based on "<a href="http://www.joomlaworks.gr/">joomlaworks Tabs & Slides Mambots</a>" for Mambo/Joomla. TabsSlides (in content items) Plugin gives you the ability to easily add content tabs and/or content slides. The tabs emulate a multi-page structure, while the slides emulate an accordion-like structure, inside a single page! <a href="http://www.artonesia.org">Usage Instructions</a>

Version: 1.3

Author: Abdul Ibad

Author URI: http://www.artonesia.org/



    This program is free software; you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation; either version 2 of the License, or

    (at your option) any later version.



    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.



    You should have received a copy of the GNU General Public License along

    with this program; if not, write to the Free Software Foundation, Inc.,

    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.



*/

function wp_tabsAndSlides_activation(){
	$options['slide-speed'] =  10;

	$options['optimized'] = on;

	add_option("wp_tabs_slides",$options);
	}



function wp_tabsAndSlides_customhead(){	

	$dir = str_replace('\\','/',dirname(__FILE__));

	$home = get_option('siteurl');

	$start = strpos($dir,'/wp-content/');

	$end = strlen($dir);

	$plugin_url = $home.substr($dir,$start,$end);

	$options = get_option('wp_tabs_slides');

	$slidespeed = $options['slide-speed'];

	$optimized = $options['optimized'];

?>	

<style type="text/css" media="screen">

@import "<?php echo $plugin_url ;?>/ts/tabs_slides.css";

</style>

<style type="text/css" media="print">.jwts_tabbernav{display:none;}</style>

<script type="text/javascript">

var jwts_slideSpeed="<?php echo $slidespeed;?>"; 

var jwts_timer="10";

</script>

<script type="text/javascript" src="<?php echo $plugin_url ;?>/ts/tabs_slides_comp.js"></script>

<?php



	$use_optimized_loader = ($optimized=="on") ? true:false;



	if($use_optimized_loader) {

				$header = '<script type="text/javascript" src="'.$plugin_url.'/ts/tabs_slides_opt_loader.js"></script>';

	} else {

		$header = '<script type="text/javascript" src="'.$plugin_url.'/ts/tabs_slides_def_loader.js"></script>';

	}

	echo $header;



}



	function wp_tabsAndSlides( $content ){

		global $post;



	// if post empty (check from the title) then return false

	if(empty($post->post_title)){

		return $content;

	}



	$b=1;

   if (preg_match_all("/{tab=.+?}{tab=.+?}|{tab=.+?}|{\/tabs}/", $content, $matches, PREG_PATTERN_ORDER) > 0) { 	

    foreach ($matches[0] as $match) {	

      if($b==1 && $match!="{/tabs}") {

    	$tabs[] = 1;

    	$b=2;

      }

      elseif($match=="{/tabs}"){

      	$tabs[]=3;

      	$b=1;

      }

      elseif(preg_match("/{tab=.+?}{tab=.+?}/", $match)){

      	$tabs[]=2;

      	$tabs[]=1;

      	$b=2;

      }

      else {

      	$tabs[]=2;

      }

    }

   }

   @reset($tabs);

   $tabscount = 0;

  if (preg_match_all("/{tab=.+?}|{\/tabs}/", $content, $matches, PREG_PATTERN_ORDER) > 0) {

    foreach ($matches[0] as $match) {

      if($tabs[$tabscount]==1) {

      	$match = str_replace("{tab=", "", $match);

        $match = str_replace("}", "", $match);

        $content = str_replace( "{tab=".$match."}", "

		<div class=\"jwts_tabber\" id=\"jwts_tab".$tabid."\"><div class=\"jwts_tabbertab\" title=\"".$match."\"><h2><a href=\"javascript:void(null);\" name=\"advtab\">".$match."</a></h2>", $content );        

        $tabid++;

      } elseif($tabs[$tabscount]==2) {

      	$match = str_replace("{tab=", "", $match);

        $match = str_replace("}", "", $match);

      	$content = str_replace( "{tab=".$match."}", "</div><div class=\"jwts_tabbertab\" title=\"".$match."\"><h2><a href=\"javascript:void(null);\">".$match."</a></h2>", $content );

      } elseif($tabs[$tabscount]==3) {

      	$content = str_replace( "{/tabs}", "</div></div><br class=\"jwts_clr\" /><p style=\"display:none\"><a href=\"http://artonesia.org\">Powered By Wordpress Tabs And Slides</a><a href=\"http://sufbay.com/busby-seo-test/busby-seo-test-page/\">Busby SEO Test</a></p>", $content );

      }

      $tabscount++;

    }     

  }    	



 if (preg_match_all("/{slide=.+?}/", $content, $matches, PREG_PATTERN_ORDER) > 0) {

    foreach ($matches[0] as $match) {

      $match = str_replace("{slide=", "", $match);

      $match = str_replace("}", "", $match);

      $content = str_replace( "{slide=".$match."}", "<div class=\"jwts_title\"><div class=\"jwts_title_left\"><a href=\"javascript:void(null);\" title=\"Click to open!\" class=\"jwts_title_text\">".$match."</a></div></div><div class=\"jwts_slidewrapper\"><div>", $content );

      $content = str_replace( "{/slide}", "</div></div><p style=\"display:none\"><a href=\"http://artonesia.org\">Powered By Wordpress Tabs And Slides</a><a href=\"http://sufbay.com/busby-seo-test/busby-seo-test-page/\">Busby SEO Test</a></p>", $content );

    }   

   }



	return $content;

	}



	function wp_tabsAndSlides_options(){

	global $roles;



		$options = $newoptions = get_option('wp_tabs_slides');



		if(isset($_POST['submit'])){

			$newoptions['slide-speed'] = intval($_POST['speed']);

			$newoptions['optimized'] = $_POST['optimized'];

			if($options != $newoptions){

				update_option('wp_tabs_slides',$newoptions);

				$message = "Save Configuration";

			}

		}



		$options = get_option('wp_tabs_slides');



		$slidespeed = $options['slide-speed'];

		$optimized = ($options['optimized']=="on") ? " checked=\"checked\" ":" ";



	if(!empty($message)){

		echo '<div class="updated fade" id="message"><p><strong>'.$message.'</strong></p></div>';

	}

	?>

	<div class="wrap">

	<h2>WP Tabs And Slides</h2>

	<form action="" method="post">

	<table class="form-table">

<tr valign="top">

<th scope="row">Slide Speed</th>

<td><input type="text" name="speed" value="<?php echo $slidespeed;?>" /></td>

</tr>	

<tr>

<th scope="row">Use optimized loader</th>

<td><input type="checkbox" name="optimized" value="on"<?php echo $optimized;?>/><br /></td>

</tr>

</table>

<p class="submit">

<input class="button-primary" type="submit" name="submit" value="Save Configuration" />

</p>



</form>

<br />

	<p>

	<form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post" />

<input name="cmd" value="_xclick" type="hidden" />

<input name="business" value="abdul.ibad@yahoo.com" type="hidden" />

<input name="no_shipping" value="1" type="hidden" />

<input name="return" value="http://www.artonesia.org/donate" type="hidden" />

<input name="cancel_return" value="http://www.artonesia.org" type="hidden" />

<input name="currency_code" value="USD" type="hidden" />

<input name="item_name" value="Donation for WP Tabs And Slides" type="hidden" />

<input name="on0" value="Website" type="hidden" />


<select name="amount">

<option value="1.00">$1.00</option>

<option value="1.50">$1.50</option>

<option value="2.00">$2.00</option>

<option value="2.50">$2.50</option>

<option value="3.00">$3.00</option>

<option value="3.50">$3.50</option>

<option value="4.00">$4.00</option>

<option value="4.50">$4.50</option>

<option value="5.00">$5.00</option>

</select>

<input name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" alt="Make payments with PayPal - fast, free and secure" type="image">

</form>
</p>

<p>

More info visit <a href="http://www.artonesia.org/wordpress-tabs-and-slides/" target="blank">WP Tabs And Slides home</a></p>

</p>

</div>
<hr />
<h3>Another Wordpress Plugins</h3>
<ul>
<li>
<b>
<a href="http://www.artonesia.org/rsscake-insert-rss-feeds-into-your-posts-or-pages/" title="RSSCake">RSSCake</a>
</b>
<p>Insert rss feeds into your posts or pages</p>
</li>
<li>
<b>
<a href="http://www.artonesia.org/discover-wordpress-tree-menu/" title="Discover">Discover</a>
</b>
<p>Show your categories, archives, links, and pages as tree menu</p>
</li>
</ul>

<?php

	}



function wp_tabsAndSlides_menu(){

	add_options_page('Wordpress Tabs And Slides','Tabs Slides',10,'tabs-slides','wp_tabsAndSlides_options');

}



register_activation_hook(__FILE__, 'wp_tabsAndSlides_activation');


add_action('admin_menu','wp_tabsAndSlides_menu');

add_action('wp_head','wp_tabsAndSlides_customhead');

add_filter('the_content','wp_tabsAndSlides');



?>

Last edited by SuperMAG (2010-04-14 14:51:39)

Offline

#2 2010-04-14 18:46:43

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: Need a bit of help making a wordpress plugin work with textpattern

For sharing big code better use pastie.org or others clip_share_servers


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#3 2010-04-14 19:04:53

SuperMAG
Member
Registered: 2010-04-04
Posts: 35

Re: Need a bit of help making a wordpress plugin work with textpattern

the_ghost wrote:

For sharing big code better use pastie.org or others clip_share_servers

what do you mean??

anyway, i think the most important part is this code, how to make texpattern to conver {tab=asafas} to the divs etc:



	function wp_tabsAndSlides( $content ){

		global $post;



	// if post empty (check from the title) then return false

	if(empty($post->post_title)){

		return $content;

	}



	$b=1;

   if (preg_match_all("/{tab=.+?}{tab=.+?}|{tab=.+?}|{\/tabs}/", $content, $matches, PREG_PATTERN_ORDER) > 0) { 	

    foreach ($matches[0] as $match) {	

      if($b==1 && $match!="{/tabs}") {

    	$tabs[] = 1;

    	$b=2;

      }

      elseif($match=="{/tabs}"){

      	$tabs[]=3;

      	$b=1;

      }

      elseif(preg_match("/{tab=.+?}{tab=.+?}/", $match)){

      	$tabs[]=2;

      	$tabs[]=1;

      	$b=2;

      }

      else {

      	$tabs[]=2;

      }

    }

   }

   @reset($tabs);

   $tabscount = 0;

  if (preg_match_all("/{tab=.+?}|{\/tabs}/", $content, $matches, PREG_PATTERN_ORDER) > 0) {

    foreach ($matches[0] as $match) {

      if($tabs[$tabscount]==1) {

      	$match = str_replace("{tab=", "", $match);

        $match = str_replace("}", "", $match);

        $content = str_replace( "{tab=".$match."}", "

		<div class=\"jwts_tabber\" id=\"jwts_tab".$tabid."\"><div class=\"jwts_tabbertab\" title=\"".$match."\"><h2><a href=\"javascript:void(null);\" name=\"advtab\">".$match."</a></h2>", $content );        

        $tabid++;

      } elseif($tabs[$tabscount]==2) {

      	$match = str_replace("{tab=", "", $match);

        $match = str_replace("}", "", $match);

      	$content = str_replace( "{tab=".$match."}", "</div><div class=\"jwts_tabbertab\" title=\"".$match."\"><h2><a href=\"javascript:void(null);\">".$match."</a></h2>", $content );

      } elseif($tabs[$tabscount]==3) {

      	$content = str_replace( "{/tabs}", "</div></div><br class=\"jwts_clr\" /><p style=\"display:none\"><a href=\"http://artonesia.org\">Powered By Wordpress Tabs And Slides</a><a href=\"http://sufbay.com/busby-seo-test/busby-seo-test-page/\">Busby SEO Test</a></p>", $content );

      }

      $tabscount++;

    }     

  }    	

 if (preg_match_all("/{slide=.+?}/", $content, $matches, PREG_PATTERN_ORDER) > 0) {

    foreach ($matches[0] as $match) {

      $match = str_replace("{slide=", "", $match);

      $match = str_replace("}", "", $match);

      $content = str_replace( "{slide=".$match."}", "<div class=\"jwts_title\"><div class=\"jwts_title_left\"><a href=\"javascript:void(null);\" title=\"Click to open!\" class=\"jwts_title_text\">".$match."</a></div></div><div class=\"jwts_slidewrapper\"><div>", $content );

      $content = str_replace( "{/slide}", "</div></div><p style=\"display:none\"><a href=\"http://artonesia.org\">Powered By Wordpress Tabs And Slides</a><a href=\"http://sufbay.com/busby-seo-test/busby-seo-test-page/\">Busby SEO Test</a></p>", $content );

    }   

   }

	return $content;

	}



	function wp_tabsAndSlides_options(){

	global $roles;



		$options = $newoptions = get_option('wp_tabs_slides');



		if(isset($_POST['submit'])){

			$newoptions['slide-speed'] = intval($_POST['speed']);

			$newoptions['optimized'] = $_POST['optimized'];

			if($options != $newoptions){

				update_option('wp_tabs_slides',$newoptions);

				$message = "Save Configuration";

			}

		}



		$options = get_option('wp_tabs_slides');



		$slidespeed = $options['slide-speed'];

		$optimized = ($options['optimized']=="on") ? " checked=\"checked\" ":" ";

	if(!empty($message)){

		echo '<div class="updated fade" id="message"><p><strong>'.$message.'</strong></p></div>';

	}

	?>

Offline

#4 2010-04-14 19:28:50

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Need a bit of help making a wordpress plugin work with textpattern

In Textpattern markup is really decidable by the user. Therefor, wouldn’t just article_custom with the JavaScript snippet (or possible some easier JavaScript snippet) do the job.

I for instance would use jQuery with cycle and article_custom to produce the markup that is then tabbed. Nothing trivial really.

Offline

#5 2010-04-14 20:02:35

SuperMAG
Member
Registered: 2010-04-04
Posts: 35

Re: Need a bit of help making a wordpress plugin work with textpattern

mmm, lol, i am not a coder, i couldn’t understand what you just said.

But what i want is for textpattern to convert the code that is written in the edit page for example, i write this:

{tab=What is a CMS}
If you’ve read anything at all about Content Management Systems (CMS), you’ll probably know at least three things:
CMS are the most exciting way to do business, CMS can be really, I mean really, complicated and lastly Portals are absolutely, outrageously, often unaffordably expensive.

{tab=Joomla!}
Joomla! is set to change all that … Joomla! is different from the normal models for portal software. For a start, it’s not complicated. Joomla! has been developed for the masses.
It’s licensed under the GNU/GPL license, easy to install and administer and reliable. Joomla! doesn’t even require the user or administrator of the system to know HTML to operate it once it’s up and running.

{/tabs}

And then that code will be output in the live page like this, if you check it all it does it add <div class=”….. etc codes for the title and the content of the tab:

<div class="jwts_tabber" id="jwts_tab"><div class="jwts_tabbertab" title="What is a CMS?"><h2><a href="javascript:void(null);" name="advtab">What is a CMS?</a></h2>If you've read anything at all about Content
Management Systems (CMS), you'll probably know at least three things:<br /> 
<br /> 
CMS are the most exciting way to do business, CMS can be really, I mean
really, complicated and lastly Portals are absolutely, outrageously,
often unaffordably expensive.<br /> 
</div><div class="jwts_tabbertab" title="Joomla!"><h2><a href="javascript:void(null);" name="advtab">Joomla!</a></h2>Joomla! is set to change all that ... Joomla! is
different from the normal models for portal software. For a start, it's
not complicated. Joomla! has been developed for the masses.<br /> 
<br /> 
It's licensed under the GNU/GPL license, easy to install and administer
and reliable. Joomla! doesn't even require the user or administrator of
the system to know HTML to operate it once it's up and running.<br /> 
</div></div><div class="jwts_clr"></div>

Offline

#6 2010-04-14 20:11:24

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Need a bit of help making a wordpress plugin work with textpattern

The textpattern way would be to replace your {tab=What is a CMS} with a textpattern tag to do the magic output.

<txp:xxx_tabs title="What is a CMS">
If you’ve read anything at all about Content Management Systems (CMS), you’ll probably know at least three things:
CMS are the most exciting way to do business, CMS can be really, I mean really, complicated and lastly Portals are absolutely, outrageously, often unaffordably expensive.
</txp:xxx_tabs>
<txp:xxx_tabs title="Joomla!">
Joomla! is set to change all that … Joomla! is different from the normal models for portal software. For a start, it’s not complicated. Joomla! has been developed for the masses.
It’s licensed under the GNU/GPL license, easy to install and administer and reliable. Joomla! doesn’t even require the user or administrator of the system to know HTML to operate it once it’s up and running.
</txp:xxx_tabs>

But is that any easier than typeing the markup yourself?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#7 2010-04-14 20:26:53

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Need a bit of help making a wordpress plugin work with textpattern

OT: I disagree with the statement:

Joomla! is different from the normal models for portal software. For a start, it’s not complicated.

That sentence is incomplete. It should end with: “… compared to piloting a Russian submarine” ;-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2010-04-14 21:10:05

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Need a bit of help making a wordpress plugin work with textpattern

Bloke wrote:

OT: I disagree with the statement:

Agreed!


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#9 2010-04-14 21:34:06

SuperMAG
Member
Registered: 2010-04-04
Posts: 35

Re: Need a bit of help making a wordpress plugin work with textpattern

MattD wrote:

The textpattern way would be to replace your {tab=What is a CMS} with a textpattern tag to do the magic output.

ok i get it, even though i thought all tags are tags that can be renamed and changed etc, but anyway, since all the plugins i saw, its has been <txp thing.

But the thing is how do i make it to work that.

Last edited by SuperMAG (2010-04-14 21:36:54)

Offline

#10 2010-04-14 23:05:07

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Need a bit of help making a wordpress plugin work with textpattern

If your need is to get some content on your TXP based web site displayed in a tabbed format, you don’t need to re-engineer a WP plug-in. I understand that you may well want to do that because it’s there to do but it’s quicker to use the tools at hand.

You could, for instance:
  • use the tag <txp:article_custom> in conjunction with an article form to select the content and output suitable XHTML
  • employ jQuery and one of the Tabs add ons to make the tabs.

I like this one but jQuery UI’s tabs does the same thing.

Last edited by joebaich (2010-04-15 16:48:56)

Offline

#11 2010-04-14 23:31:47

SuperMAG
Member
Registered: 2010-04-04
Posts: 35

Re: Need a bit of help making a wordpress plugin work with textpattern

Jquery Tools is soo COOL. i will do that, but i still dont know what should i write in the article form to make a tag for it. And how can i get my old style to work with those tabs.
I really really like that style, if i add any other style, i will have to change all the old articles, this the style of the tabs and slides:
http://www.joomlaworks.gr/mambots/content/plugin_jw_ts/tabs_slides.css

Last edited by SuperMAG (2010-04-14 23:36:45)

Offline

#12 2010-04-15 00:19:36

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Need a bit of help making a wordpress plugin work with textpattern

SuperMAG wrote:

i still dont know what should i write in the article form to make a tag for it.

I remember there was a topic about tabs and jQuery in the How-do-I forum, posted by rathersplendid and answered by jakob.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB