SimplePortal
Customization => Custom Coding => Topic started by: Nabil on December 19, 2008, 06:45:23 AM
-
hi everyone , after I had some problems with installing the Ad Management Mod with my custom Theme , I thought of making an ad Block from HTML block , the idea is simple just write '#ad' as a title and the block will turn into an ad block , its a normal block the only difference you won't see the frames like a block and also no title bar, it will display only the contents which could be a Banner , a google Ad Sense advertisment etc. here is the Code :
in SportalBlocks1-1.template.php find :
echo '
<div class="tborder">
<table class="bordercolor" width="100%">
<tr class="catbg">
<td style="padding: 5px;">';
if(empty($block['force_view']))
echo '
<a style="float:right;" href="javascript:void(0);" onclick="doCollapseObject(\'sp_block' . $block['id'], '\', \'', $settings['csect_cookie'], '\')"><img id="img_sp_block', $block['id'], '" src="', $settings['images_url'], $block['collapsed'] ? '/expand.gif' : '/collapse.gif', '" alt="*" border="0" /></a>';
echo '
', parse_bbc($block['label']), '
</td>
</tr>
<tr class="windowbg" ', (empty($block['force_view']) ? 'id="sp_block' . $block['id'] . '"' : '') , $block['collapsed'] ? ' style="display:none;"' : '', '>
<td style="padding: 5px;">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>
</div>
<br />';
Replace with :
////////////// AD BLOCK Check //////////////
$adblock=$block['label'];
if (substr($adblock,0,3)=='#ad'){
echo '<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td align="center">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>';
} else {
echo '
<div class="tborder">
<table class="bordercolor" width="100%">
<tr class="catbg">
<td style="padding: 5px;">';
if(empty($block['force_view']))
echo '
<a style="float:right;" href="javascript:void(0);" onclick="doCollapseObject(\'sp_block' . $block['id'], '\', \'', $settings['csect_cookie'], '\')"><img id="img_sp_block', $block['id'], '" src="', $settings['images_url'], $block['collapsed'] ? '/expand.gif' : '/collapse.gif', '" alt="*" border="0" /></a>';
echo '
', parse_bbc($block['label']), '
</td>
</tr>
<tr class="windowbg" ', (empty($block['force_view']) ? 'id="sp_block' . $block['id'] . '"' : '') , $block['collapsed'] ? ' style="display:none;"' : '', '>
<td style="padding: 5px;">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>
</div>
<br />';
}
////////////// END ///////////
-
Nice do you have an example of this mod in action, a url link.
-
Nice do you have an example of this mod in action, a url link.
it is not a Mod , it is a change I have made on adding a html block function (a function found in Simple Portal) the change will hide/remove the borders and the title bar of a block letting only the inside of a block to be seen , like the following image .. you can see , that the ad is displayed as it is without a block surrounding it.
-
Hi there,
i found out that your modification is interesting and useful.
however, i have tried but it don't seem to be materialized.
anyone can help me to testify the mod i have done, pleasee?
attached is the SPortalBlocks1-1.template.php
thanks very much.
-
I have tested your 'SPortalBlocks1-1.template' , it works
so what's the problem?
-
Im not sure why.
Well im a newbie on SMF.
Im using the overviewlight theme by dziner studio.
i cant find the SPortalBlocks1-1.template.php file anywhere except from the default theme directory.
Is there any other location of the SPortalBlocks1-1.template.php file that i should edit?
thanks a lot :nervous-happy:
-
Is there any other location of the SPortalBlocks1-1.template.php file that i should edit?
I have it in my Theme's Directory
-
Hi Nabil,
thanks for trying to help me out. but i cant find the file in my Theme's directory.
Uploaded the file to my Theme's directory though, but it didnt work.
Anyway, u can see it here at my site. the ad has the header '#ad'.
http://ftmk.putrabytes.com (http://ftmk.putrabytes.com)
-
Im not sure why.
Well im a newbie on SMF.
Im using the overviewlight theme by dziner studio.
i cant find the SPortalBlocks1-1.template.php file anywhere except from the default theme directory.
Is there any other location of the SPortalBlocks1-1.template.php file that i should edit?
thanks a lot :nervous-happy:
I'm using the Overview Multicolor, and the my SPortalBlocks1-1.template.php is only in the folder of the default.
Hi Nabil,
thanks for trying to help me out. but i cant find the file in my Theme's directory.
Uploaded the file to my Theme's directory though, but it didnt work.
Anyway, u can see it here at my site. the ad has the header '#ad'.
http://ftmk.putrabytes.com (http://ftmk.putrabytes.com)
Could it be you have add '#ad' as title of the block instead of a name for the block? Don't know how to explain it in English. :-[
-
Hi Manu,
Im not sure what do u mean, but im putting '#ad' as my block name.
Attached is the image on how i filled up the html block.
Is there anything wrong?
-
Now I see I was wrong.
The '#ad' should remove all the borders of the block itself. :-[
I think that's something for our Dev's, cause that's to much php for me. :-[
Sorry, but here I can't help you. :-[
-
it did not work in your case as I can see from the attached image because you didn't write at the beginning the '<?php' , the php block is not like a normal php site you should write that symbol , just write something like
<?php
///////////// ///////////////////
?>
at the begining of your code and it will go
by the way the name of the block is not only limited to #ad , you can give it #adname1 or #adname2 or #adname3 , any name after #ad
I can also see in the image that you have givin the name '#ad'
write #ad not '#ad'
-
Hello,
thanks for all the replies. It really helped!
Now the ads are borderless :D
Thank you, thank you.
-
Hi I tried this on a SPortalBlocks2.template but it didn't work. Here is the code:
$adblock=$block['label'];
if (substr($adblock,0,3)=='#ad'){
echo '<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td align="center">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>';
} else {
echo '
<div class="tborder">
<table class="bordercolor" width="100%">
<tr class="catbg">
<td style="padding: 5px;">';
if(empty($block['force_view']))
echo '
<a style="float: right;" href="javascript:void(0);" onclick="doCollapseObject(\'sp_block' . $block['id'], '\', \'', $settings['csect_cookie'], '\')"><img id="img_sp_block', $block['id'], '" src="', $settings['images_url'], $block['collapsed'] ? '/expand.gif' : '/collapse.gif', '" alt="*" border="0" /></a>';
echo '
', parse_bbc($block['label']), '
</td>
</tr>
<tr class="windowbg" ', (empty($block['force_view']) ? 'id="sp_block' . $block['id'] . '"' : '') , $block['collapsed'] ? ' style="display:none;"' : '', '>
<td style="padding: 5px;">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>
</div>
<br />';
}
Can someone help me? ;D
-
anyone? :'(
-
That Code is made for sp with smf 1.x.x , so it has to be modified to work with smf2 , but I did a simple test with sp & smf2 , replaced SportalBlocks1-1.template.php instead of SportalBlocks2.template.php by renaming it to SportalBlocks2.template.php , I didn't see any change actually , so you can apply the code for SportalBlocks1-1.template.php and use it instead of SportalBlocks2.template.php , but keep a backup copy of the Original SportalBlocks2.template.php , do this at your own risk I didnt test all the Blocks , just php and html
-
worked perfect for me!
-
1) I have edited the file SPortalBlocks1
2) I have created a block for google adsense ads, the block type is set to "HTML"
3) I put the google ads code within the blocks
4) I have named the block #adFirst
what I'm doing wrong?
-
I have edited the file SPortalBlocks1
you mean SPortalBlocks1-1.template.php dont you?
this is how a google code inside a HTML block looks like
<script type="text/javascript"><!--
google_ad_client = "pub-6566546455656
/* 728x90, text only */
google_ad_slot = "zttzztzt";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pgad.goolesyztztndcaion.com/pagea/show_ads.js">
</script><br>
-
yes, that's what I meant
this block wont show either using #ad or the regular block, I'm just getting empty space, like it's not being recognized
-
Can I see your SPortalBlocks1-1.template.php ?
-
Can I see your SPortalBlocks1-1.template.php ?
<?php
/*
File: SPortalBlocks1-1.template.php
Version: SimplePortal 2.1.1 for SMF 1.x
*/
function template_portal_above()
{
global $context, $modSettings;
sp_collapse_script();
echo '
<table cellpadding="5px" width="100%">
<tr>';
if(!empty($modSettings['showleft']) && !empty($context['SPortal']['blocks']['Left']))
{
echo '
<td valign="top"', !empty($modSettings['leftwidth']) ? ' width="' . $modSettings['leftwidth'] . '"' : '', '>';
foreach ($context['SPortal']['blocks']['Left'] as $block)
template_block($block);
echo '
</td>';
}
echo '
<td valign="top">';
foreach ($context['SPortal']['blocks']['Middle-Top'] as $block)
template_block($block);
}
function template_portal_below()
{
global $context, $modSettings;
echo '
<br />';
foreach ($context['SPortal']['blocks']['Middle-Bottom'] as $block)
template_block($block);
echo '
</td>';
if(!empty($modSettings['showright']) && !empty($context['SPortal']['blocks']['Right']))
{
echo '
<td valign="top"', !empty($modSettings['rightwidth']) ? ' width="' . $modSettings['rightwidth'] . '"' : '', '>';
foreach ($context['SPortal']['blocks']['Right'] as $block)
template_block($block);
echo '
</td>';
}
echo '
</tr>
</table>';
}
function template_block($block)
{
global $settings;
if(empty($block['force_view']))
$block['collapsed'] = sp_collapse_state('sp_block' . $block['id']);
else
$block['collapsed'] = false;
if ($block['type'] == 'sp_boardNews')
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
echo '
<br />';
return;
}
/*
echo '
<div class="tborder">
<table class="bordercolor" width="100%">
<tr class="catbg">
<td style="padding: 5px;">';
if(empty($block['force_view']))
echo '
<a style="float:right;" href="javascript:void(0);" onclick="doCollapseObject(\'sp_block' . $block['id'], '\', \'', $settings['csect_cookie'], '\')"><img id="img_sp_block', $block['id'], '" src="', $settings['images_url'], $block['collapsed'] ? '/expand.gif' : '/collapse.gif', '" alt="*" border="0" /></a>';
echo '
', parse_bbc($block['label']), '
</td>
</tr>
<tr class="windowbg" ', (empty($block['force_view']) ? 'id="sp_block' . $block['id'] . '"' : '') , $block['collapsed'] ? ' style="display:none;"' : '', '>
<td style="padding: 5px;">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>
</div>
<br />';
*/
////////////// AD BLOCK Check //////////////
$adblock=$block['label'];
if (substr($adblock,0,3)=='#ad'){
echo '<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td align="center">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>';
} else {
echo '
<div class="tborder">
<table class="bordercolor" width="100%">
<tr class="catbg">
<td style="padding: 5px;">';
if(empty($block['force_view']))
echo '
<a style="float:right;" href="javascript:void(0);" onclick="doCollapseObject(\'sp_block' . $block['id'], '\', \'', $settings['csect_cookie'], '\')"><img id="img_sp_block', $block['id'], '" src="', $settings['images_url'], $block['collapsed'] ? '/expand.gif' : '/collapse.gif', '" alt="*" border="0" /></a>';
echo '
', parse_bbc($block['label']), '
</td>
</tr>
<tr class="windowbg" ', (empty($block['force_view']) ? 'id="sp_block' . $block['id'] . '"' : '') , $block['collapsed'] ? ' style="display:none;"' : '', '>
<td style="padding: 5px;">';
if(in_array($block['type'], array('sp_bbc', 'sp_html', 'sp_php')))
{
$block['type']($block['content']);
}
else
{
$parameters = explode(',', $block['parameters']);
$block['type']($parameters);
}
echo '
</td>
</tr>
</table>
</div>
<br />';
}
////////////// END ///////////
}
function sp_collapse_state($block_id)
{
global $settings;
if(isset($settings['collapsed_sects']) && !empty($settings['collapsed_sects']))
{
if(array_search($block_id, $settings['collapsed_sects']) === false)
return false;
else
return true;
}
return false;
}
function sp_collapse_script()
{
global $settings, $context;
$csect_cookie = 'SMF_user_' . $context['user']['id'] . '_CSect';
if(isset($_COOKIE[$csect_cookie]) && !empty($_COOKIE[$csect_cookie]))
$settings['collapsed_sects'] = explode("\n", $_COOKIE[$csect_cookie]);
$settings['csect_cookie'] = $csect_cookie;
echo'
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var dom_engine = \'\';
if (document.getElementById)
dom_engine = 1; // mozilla, opera etc..
else if (document.all)
dom_engine = 0; // IE (pls die, kthx)
else if (document.layers)
dom_engine = 2; // NS4, should never happen :P
var active_menu = "";
var mouse_over_menu = "";
function getObject(id)
{
if(dom_engine == 1)
obj = document.getElementById(id);
else if(dom_engine == 0)
obj = document.all[id];
else if(dom_engine == 2)
obj = document.layers[id];
return obj;
}
function getCookieFromDocument(cookie_name)
{
cname = cookie_name + "=";
clength = document.cookie.length;
begin = 0;
while (begin < clength) {
vbegin = begin + cname.length;
if (document.cookie.substring(begin, vbegin) == cname) {
var end = document.cookie.indexOf (";", vbegin);
if (end == -1) {
end = clength;
}
return unescape(document.cookie.substring(vbegin, end));
}
begin = document.cookie.indexOf(" ", begin) + 1;
if (begin == 0) {
break;
}
}
return null;
}
function setCookieToDocument(cookie_name, cookie_expiredate, cookie_value)
{
document.cookie=cookie_name+"="+escape(cookie_value)+"; expires="+cookie_expiredate.toGMTString()+"; path=/";
}
function saveObjectToCookie(obj, mode, cookiename)
{
var already_collapsed=getCookieFromDocument(cookiename);
var temp = new Array();
cookieExpireDate = new Date();
cookieExpireDate.setTime(cookieExpireDate.getTime() + 86400*1000*300); // 300 days expiration date
if (already_collapsed) {
already_collapsed = already_collapsed.split("\n");
for (i in already_collapsed) {
if (already_collapsed != obj && already_collapsed != "")
temp[temp.length] = already_collapsed;
}
}
if (mode)
temp[temp.length] = obj;
setCookieToDocument(cookiename, cookieExpireDate, temp.join("\n"));
}
function doCollapseObject(id, cookiename)
{
obj = getObject(id);
imageid = getObject("img_" + id);
tempobj = getObject(id);
if (obj.style.display == "none") { // object is collapsed, show it, clear the cookie
obj.style.display = "";
saveObjectToCookie(id, 0, cookiename);
if (imageid) {
imageid.src = imageid.src.replace(\'expand.gif\', \'collapse.gif\');
}
} else { // hide the object, save it to the cookie
obj.style.display = "none";
saveObjectToCookie(id, 1, cookiename);
if (imageid) {
imageid.src = imageid.src.replace(\'collapse.gif\', \'expand.gif\');
}
}
return false;
}
// ]]></script>';
}
?>
there it is, thanks a lot
-
your SPortalBlocks1-1.template.php file works as expected , do you have it in your Custom Theme Directory?
-
your SPortalBlocks1-1.template.php file works as expected , do you have it in your Custom Theme Directory?
no, I have it in /Themes/default
but now checked with all 3 files in /Themes/kelo and still "no go" :(
-
I have tested your file with another Theme , where the SPortalBlocks1-1.template.php in the default Theme , it works also 100% as expected with no problem at all, I beleive it has nothing to do with the SPortalBlocks1-1.template.php , see if the Code you are using in the Block if it really displays something or not , test it with a normal block
-
have a look at the bottom here: http://polacywlimerick.com/forum/index.php
here's my code:
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxx";
google_ad_slot = "xxxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pgad.goolesyztztndcaion.com/pagea/show_ads.js">
</script><br>
-
the Google Code seems like a usual Code , nothing unusual , but
it doesn't show anything
this block wont show either using #ad or the regular block, I'm just getting empty space
and since this is the case also with a normal Block , then we can
say with 100% its a google script problem