Member 3639
Active member
Any idea how i can put php code in a block guys?
You can call php file without any problem. Just use any existing blocks or make your own.
Here is a simple example that shows one way how to include php file.
The ads when clicked directs the page to the corresponding websites. Instead of this is there any way we can open a new browser or tab for all these clicks so that we can prevent the users from going out of our forums.
I am using Adsense block. When we click on ads it doesn't open up the ads in a new browser or tabs. The purpose is to keep our users on our forums even if they want to check some ads listed.
Is there any way?
Can I open the ads in a new window?
Generally, it is our policy to not allow Google ads to open in a new window. However, in a few markets, including China, we've found that opening ads in a new window better aligns with expected internet behavior and provides a more consistent, intuitive user experience.
Keeping in mind the importance of the user experience, we've enabled Google ads to open in new windows in locations where this is expected browsing behavior. This functionality is determined by the IP of the user, and is not an option you can select your AdSense account.
We also ask that you don't modify the AdSense ad code or alter the result of clicking on an ad on your website, as such behavior violates our program policies.
I am trying to make a php block that will grab rows from a mysql table and just print them out each on a new line
Thanks for you help Agsteve. Would you be super kind enough to help me fix this?It's not an option using Google Adsense, it's hard coded in their script. Here is their FAQ on the subject -
Make "MyphpBlock" block and MyphpBlock.php Use any name you want but make sure you use exactly the same name when you name the files (red mark).
<?php
class EWRporta_Block_MyphpBlock extends XenForo_Model
{
public function getModule()
{
//Your sql query
$mystuff = $this->_getDb()->fetchAll('
SELECT .....
FROM .....
WHERE .....
AND .....
LIMIT...
');
foreach ($mystuff as &$stuff)
{
$stuff = array(
'one' =>$stuff['one'],
'two' => $stuff['two'],
'three' => $stuff['three'],
'four' => $stuff['four']
);
}
return $mystuff;
}
}
Use template syntax <xen:foreach> to get the data from MyphpBlock.php and print them out.
Template EWRblock_MyphpBlock
<xen:if hascontent="true">
<div>
<xen:contentcheck>
<xen:foreach loop="MyphpBlock" value="$mystuff;">
<div>
<div>
<p>{$mystuff.one}</p>
<p>{$mystuff.two}</p>
<p>{$mystuff.three}</p>
<p>{$mystuff.four}</p>
</div>
</div>
</xen:foreach>
</xen:contentcheck>
</div>
</xen:if>
<?php
class EWRporta_Block_Articles extends XenForo_Model
{
public function getModule()
{
$mystuff = $this->_getDb()->fetchAll('SELECT * FROM `articles_category` ORDER BY `category_name` ASC');
foreach ($mystuff as &$stuff)
{
$stuff = array(
'one' => $stuff['category_name']
);
}
return $mystuff;
}
}
<xen:if hascontent="true">
<div>
<xen:contentcheck>
<xen:foreach loop="Articles" value="$mystuff;">
<div>
<div>
<p>{$mystuff.one}</p>
</div>
</div>
</xen:foreach>
</xen:contentcheck>
</div>
</xen:if>
<?xml version="1.0" encoding="utf-8"?>
<module>
<module_name>Homepage</module_name>
<module_cache>+1 day</module_cache>
<module_settings/>
<module_template><![CDATA[
<div class="sectionMain baseHtml">
<div class="sectionFooter">
<span class="custom-h1">Welcome to escopride</span>
</div>
<div class="primaryContent" style="border-bottom:none;">
<div class="messageContent">
<p>My test goes here, will be added soon</p>
</div>
</div>
</div>
<div class="sectionMain baseHtml">
<div class="sectionFooter">
<span class="custom-h1">Our News</span>
</div>
<div class="primaryContent" style="border-bottom:none;">
<div class="messageContent">
<img src="http://www.ptsdforum.org/c/images/article.jpg" alt="" style="float:left;padding-right:10px;" />
<p>Welcome.</p>
</div>
<div style="clear:left"></div>
</div>
</div>
]]></module_template>
</module>
We use essential cookies to make this site work, and optional cookies to enhance your experience.