PDA

View Full Version : Help Please - Overriding a Charset


Satviewers
03-11-2010, 03:19 AM
Hi,

Is there a way to set the Charset to utf-8 on an integrated product and leave the default charset set in the Admincp left alone.

Satviewers
03-12-2010, 12:43 PM
Help please

borbole
03-12-2010, 01:22 PM
Can you explain a little bit more please? Do you mean you have a third paty mod integrated with vb and you want its tables to be converted to utf-8 but not the vb ones? If so, yes it can be done.

Satviewers
03-12-2010, 07:58 PM
Here is an example of what I have.

I created a plugin called oscShop Body.
Hook Location is gobal_start
Code in the plugin is:
if (THIS_SCRIPT == 'osc_shop')
{
ob_start();
include('./packages/shop/index.php');
$includeshopbody = ob_get_contents();
ob_end_clean();
}


My template is oscShop
Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta id="e_vb_meta_bburl" name="vb_meta_bburl" content="{vb:raw vboptions.bburl}" />
<base href="{vb:raw vboptions.bburl}/" /><!--[if IE]></base><![endif]-->
<meta name="generator" content="vBulletin {vb:raw vboptions.templateversion}" />

<vb:if condition="$show['threadinfo']">

<vb:elseif condition="$show['foruminfo']" />
<meta name="keywords" content="{vb:raw foruminfo.title_clean}, {vb:raw vboptions.keywords}" />
<meta name="description" content="<vb:if condition="$pagenumber > 1">{vb:rawphrase page_x, {vb:raw pagenumber}}-</vb:if>{vb:raw foruminfo.description_clean}" />
<vb:else />
<meta name="keywords" content="{vb:raw vboptions.keywords}" />
<meta name="description" content="{vb:raw vboptions.description}" />
</vb:if>

<script type="text/javascript" src="{vb:stylevar yuipath}/yuiloader-dom-event/yuiloader-dom-event.js?v={vb:raw vboptions.simpleversion}"></script>
<script type="text/javascript" src="{vb:stylevar yuipath}/connection/connection-min.js?v={vb:raw vboptions.simpleversion}"></script>
<script type="text/javascript">
<!--
var SESSIONURL = "{vb:raw session.sessionurl_js}";
var SECURITYTOKEN = "{vb:raw bbuserinfo.securitytoken}";
var IMGDIR_MISC = "{vb:stylevar imgdir_misc}";
var IMGDIR_BUTTON = "{vb:stylevar imgdir_button}";
var vb_disable_ajax = parseInt("{vb:raw vboptions.disable_ajax}", 10);
var SIMPLEVERSION = "{vb:raw vboptions.simpleversion}";
var BBURL = "{vb:raw vboptions.bburl}";
// -->
</script>
<script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-core.js?v={vb:raw vboptions.simpleversion}"></script>
{vb:raw template_hook.headinclude_javascript}

<vb:if condition="$vboptions['externalrss']">
<link rel="alternate" type="application/rss+xml" title="{vb:raw vboptions.bbtitle} {vb:rawphrase rss_feed}" href="{vb:raw vboptions.bburl}/external.php?type=RSS2" />
<vb:if condition="$show['foruminfo'] OR $show['threadinfo']">
<link rel="alternate" type="application/rss+xml" title="{vb:raw vboptions.bbtitle} - {vb:raw foruminfo.title_clean} - {vb:rawphrase rss_feed}" href="{vb:raw vboptions.bburl}/external.php?type=RSS2&amp;forumids={vb:raw foruminfo.forumid}" />
</vb:if>
</vb:if>

<vb:if condition="$vboptions['storecssasfile']">
<link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}main-rollup.css" />
{vb:raw template_hook.custom_css_links}
<vb:else />
<link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}bbcode.css,editor.css,popupmenu.css,oscS hop_reset-fonts.css,vbulletin.css,vbulletin-chrome.css,vbulletin-formcontrols.css{vb:raw template_hook.custom_css_list}" />
</vb:if>
{vb:raw template_hook.headinclude_css}

</head>

<body>
{vb:raw header}

{vb:raw navbar}

{vb:raw includeshopbody}

{vb:raw footer}
</body>

</html>


My osc_shop.php
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
$_shopfile = basename($_SERVER['SCRIPT_FILENAME'], '.php');

define('THIS_SCRIPT', $_shopfile);
define('CSRF_PROTECTION', false);

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('oscShop',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
require_once('./includes/osc_func_var.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = construct_navbits(array('' => 'cart'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'cart';



// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######


$templater = vB_Template::create('oscShop');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('includeshopbody', $includeshopbody);
print_output($templater->render());


?>



As you can see I have copied the headinclude and modified it and included it in the template above, which also has the charset defined as charset=utf-8.

borbole
03-12-2010, 08:05 PM
@Satviewers, please don''t pm me for support, but instead use the forums. Thank you for your understanding :)

Satviewers
03-12-2010, 08:12 PM
Sorry about that

borbole
03-12-2010, 08:16 PM
No problem :)

Satviewers
03-14-2010, 10:33 PM
Can anyone help with this please