• May
  • 08
  • 2012

Json on php 5.1.6

For reasons no will to explain, I’m using joomla 1.5 on PHP 5.1.6 on the year 2012, which is very much like driving a Chevy on F1.
Anyhow, I had hit a few times the problem of using extensions where json was required..

so finally i found this post “The post” with this nice solution..

1. First of all, get this file JSON, from here http://mike.teczno.com/JSON.tar.gz

2. Then put it on the same folder you are going to call it, there has to be a way to include it on the libraries, but this is already to much…

3. Next, include this at the end of the file, if you copy and paste pay attention to quotes” ”


// Future-friendly json_encode
if( !function_exists('json_encode') ) {
function json_encode($data) {
$json = new Services_JSON();
return( $json->encode($data) );
}
}

// Future-friendly json_decode
if( !function_exists('json_decode') ) {
function json_decode($data) {
if ($bool) {
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON();
}
return( $json->decode($data) );
}
}

the past code goes at the end fo the JSON.PHP before ?>
Then include the file where you need it

require_once('JSON.php');

Done

 

Last minute update***

on working on K2 the last try will cause an error, because K2 already calls json

Fatal error: Cannot redeclare class services_json in …

So, add to the k2 json.php file, the same piece of code on step,3, always at the bottom of the file. and then call it like this

require_once(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'JSON.php');
  • Feb
  • 21
  • 2012

Removing discussions tab bar from Jomsocial

To remove the discussions tab bar on jomsocial 2.4 and up
com_community->templates->default->groups.viewgroup.php
Around line: 479

<a href="javascript:void(0)">
<?php echo JText::_('COM_COMMUNITY_GROUPS_DISCUSSION');?>
<?php if($alertNewDiscussion){ echo '<span></span>'; } ?>
</a>
  • Jan
  • 10
  • 2012

Porting your users from joomla 1.0 to 1.5…More on archaeological computing

In order to export your users to Joomla 1.5 from 1.0. You need to convert the following tables..

jos_users

jos_core_acl_aro

jos_core_acl_groups_aro

That’s it..!

  • Dec
  • 01
  • 2011

Insert Reader speaker on every post, as default, Joomla 1.0

For what is worth.

This one, was like correcting Aristotelian scripts on some minimal punctuation , but anyhow…

It may help to add any other default (item module etc) in Joomla 1.0. This example to add reader speaker, with the option readthis activated, so the full content has to be contained into <div>full article</div>

May also work for list articles, but then speaker reader for joomla 1.0 do not support multiple instances of a button on the same page… some count has to be implemented to define instances of the button, but joomla 1.0 its so old, that who really cares..

In ../components/com_content/content.php

line 1594


// show/hides the intro text

	if ( $params->get( 'introtext'  ) || empty($row->fulltext) ) {
		$row->text = $row->introtext.
( $params->get( 'intro_only' ) ? '' : chr(13) . chr(13)  .$row->fulltext);
	}
 else {
		$row->text = '<p>{readspeaker}</p>
               <div id="rspeak_read_this">'.$row->fulltext.'</div>';
	}

ReadSpeaker starts in the first <p> and also reads <title> and <alt>.

  • Dec
  • 01
  • 2011

Validation of Joomulus for Joomla 1.5 as XHTML 1.0 Strict

The attributes <tags> and <target> aren’t valid XHTML 1.0  Strict.

Tag was already replaced on the original post here as commented by “akel”

Still target attribue, on a new window is considered un-polite, in my example wasn’t need, so I’d just get rid of it.. now “Validates.!”

Line 18

Code:

$tagcloud = '<tags>';


to

Code:

$tagcloud = '<span>';


Line 21:

Code:

$tagcloud2 .= "<a href='".$this- >options[$count.'_url']."' style='font-size:".$this- >options[$count.'_size']."'>".$this- >options[$count.'_name']."</a>\n ";


to

Code:

$tagcloud2 .= "<a href='".htmlentities($this- >options[$count.'_url'])."' style='font-size:".$this- >options[$count.'_size']."'>".$this- >options[$count.'_name']."</a>\n ";


and Line 29

Code:

$tagcloud .= $tagcloud2.'</tags>';


to

Code:

$tagcloud .= $tagcloud2.'</span>';


  • May
  • 06
  • 2011

about master pages

In a nutshell, a master page is a special type of ASP.NET page that defines the markup that is common among all content pages as well as regions that are customizable on a content page-by-content page basis. (A content page is an ASP.NET page that is bound to the master page.) Whenever a master page’s layout or formatting is changed, all of its content pages’ output is likewise immediately updated

 

  • May
  • 05
  • 2011

Xpath in Umbraco

Xpath syntax

Expression Description
nodename Selects all child nodes of the named node
/ Selects from the root node
// Selects nodes in the document from the current node that match the selection no matter whey they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes

Examples on Simple Xpath Syntax

//RunwayTextPage

Get a child node with the name “RunwayTextPage”

/@ID

Gets an attribute with name “ID”

/TextPage [@ID=2233]

Get TextPage Element based on an attribute value

  • May
  • 04
  • 2011

The $currentPage variable Umbraco

$currentPage

Referrers to the context in which the xslt macro is executed.
A macro is always placed on a content page, so $currentPage variable refers to that page

  • May
  • 04
  • 2011

Umbraco XSLT if/else statement

<xsl:choose>

<xsl:when test="$currentPage/@id=1234">
<h1>This is Page with ID 1234</h1>
</xsl:when>

<xsl:when test="$currentPage/@id=2000">
<h1>This is Page with ID 2000</h1>
</xsl:when>

<xsl:otherwise>
<h1>This is Page with some other ID</h1>
</xsl:otherwise>
</xsl:choose>
  • May
  • 04
  • 2011

Umbraco XSLT If Statement

<xsl:if test="$currentPage/@id=1234">
<h1>This is the page with ID 1234</h1>
</xsl:if>
UA-12442755-18