Gallery: 如何添加adsense:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
 
第107行: 第107行:
== Carbon外观主题 ==
== Carbon外观主题 ==


If you're using the carbon theme, you're in luck. 
如果你使用carbon外观主题的话,那么你很走运。


Open up your FTP program of choice and go to your '''/gallery2/themes/carbon/templates''' folder and find ads.tpl  Copy this file to your desktop.  Open it with your favorite editor of choice (you can use Notepad if you are in Windows XP) and READ THE TEXT THAT IS ALREADY THERE.  Paste in your AdSense code and wrap it all with the following tags: {literal} {/literal}. Save the file as ads.tpl (which is already is) and upload to your '''/gallery2/themes/carbon/templates/local''' folder.
启动FTP程序,打开'''/gallery2/themes/carbon/templates'''文件夹并找到ads.tpl。将此文件复制到桌面。使用文本编辑器将其打开(如果你的系统是Windows XP就使用记事本)并阅读其中已有的文本。将你的Adsense代码复制其中,并使用{literal} {/literal}标识将其包括进去。将该文件保存为ads.tpl并上传到你的'''/gallery2/themes/carbon/templates/local'''文件夹中。


Voila!  You're all done!
OK,这就成了!


--[[User:JDuc|JDuc]] 28 February 2008
--[[User:JDuc|JDuc]]2008年2月28日


for the carbon theme : in the thumbnail in the photo veiw :
针对carbon外观主题:在相片视图的缩略图中:


example
举例


http://www.pho2o.net/gallery/v/deeb/n649780189_136741_6625.jpg.html
http://www.pho2o.net/gallery/v/deeb/n649780189_136741_6625.jpg.html


go to your gallery ftp or cpanel
打开gallery ftp或cpanel


open file manger and go to the gallery folder
打开文件管理器并来到gallery文件夹


open themes
打开外观主题


open carbon
打开carbon


open templates
打开模板


edit navigatorMicroThumbs.tpl
编辑navigatorMicroThumbs.tpl


on the end of the code after {/if} add the adsense code
{/if}之后的代码末尾添加adsense代码


I never try it on another theme
我没有对另外的外观主题再做尝试了


ps : I use adesnse 120 X 600
ps :我使用的是adesnse 120 X 600


http://pho2o.net
http://pho2o.net
第147行: 第147行:
== 多个广告 ==
== 多个广告 ==


Here is another example how to add Google AdSense ads to matrix theme. I modified matrix theme and added one 200x200 ad to sidebar, one 728x90 banner and one 180x150 ad in the middle of 3x3 album/image display so that only 8 images are visible. All code and HOWTO is available here: [http://wiki.version6.net/matrixad http://wiki.version6.net/matrixad]
这里还有一个例子说明如何将Google AdSense广告添加到matrix外观主题。我对matrix外观主题做了修改并添加了一个200x200的广告至边栏,一个728x90的横幅及一个180x150的广告到3X3相册/图片显示的中央,这样只有8张图片可见了。所有代码及指导信息可以在此找到:[http://wiki.version6.net/matrixad http://wiki.version6.net/matrixad]
--[[User:Cougar|Cougar]] 08:02, 28 May 2007 (PDT)
--[[User:Cougar|Cougar]] 2007年5月28日,08:02 (PDT)


== Matrix颜色 ==
== Matrix颜色 ==

2008年11月8日 (六) 17:00的最新版本

该文描述在Gallery支持的网站中添加Google AdSense的方法,以通过Google广告获益。

该指导以默认的Gallery外观主题(matrix)为例。

添加Adsense的方法如下。

添加到头-方法一[ ]

首先使用FTP登入自己的网站,并在目前所使用外观主题下的模板文件夹中新建一个名为'local'的目录。

注:如果你使用Carbon外观主题,就无需做如下的操作了。直接下拉到指导部分即可。因为Carbon外观主题已内置有广告了。

接着在/gallery2/themes/matrix/templates/local/之下新建一个.tpl文件。

新建.tpl文件的简便又快捷的办法就是在Windows中使用记事本(不要使用写字板,因为它会将格式也带入编辑之中的)并复制进你的代码。当你保存文件时,将其扩展名改为.tpl即可。

我为其命名为adsense.tpl

编辑此文件并插入如下代码(插入位置随意,因为该文件会为空):

{php}
$adcode = <<<END
这里是你 
GOOGLE横幅的代码 
(最佳尺寸为468x60)
END;
echo $adcode;
{/php}


注:使用你Google Adsense的代码替换第一个和第二个END之间的文本。不要替换<<<END或END;

现在你需要将/gallery2/themes/matrix/templates/theme.tpl复制到/gallery2/themes/matrix/templates/local/(如果不存在的话请创建该文件夹)并对/gallery2/themes/matrix/templates/local/theme.tpl进行编辑。

在标志相关的语句行之后(</div>之前的部分)添加如下代码:

{if $theme.pageType == 'album' || $theme.pageType == 'photo'}
{g->theme include="adsense.tpl"}
{/if}

就是这样!注意我们进行测试,以保证默认情况下Google Adsense的爬虫会访问该页面。如果你使用认证以查看图片的话,就需要配置Google的adsense服务以进行认证操作,但上面的代码至少会阻止广告显示在管理页面上。

你可以在我的网站上看到实际演示的。

Kedem photosmapmyphoto

--Omrik 2006年4月17日,08:44, 17 (PDT)

实际演示:PBGallery --Paolo Brocco2006年7月13日

实际演示:MJ-Garage Gallery --JDuc2008年2月28日

添加到头-方法二[ ]

还有一个办法可以在Gallery2中添加Google AdSense。 你需要将/gallery2/themes/matrix/templates/theme.tpl复制到/gallery2/themes/matrix/templates/local/并对/gallery2/themes/matrix/templates/local/theme.tpl进行编辑。

你很可能需要创建/gallery2/themes/matrix/templates/local/文件夹。

如果你使用Carbon外观主题的话,就跳过这一部分直接看后文。

找到:

<img src="{g->url href="images/galleryLogo_sm.gif"}" width="107" height="48" alt=""/>

在此后添加Adsense代码,如果你希望将横幅居中的话,就要使用

<div align="center"><--ADSENSE CODE--></div>

你可以在我的网站上看到实际演示。

但如果你使用XP的工具来发布PC上的相片的话就必须禁用代码,你可以将/gallery2/themes/matrix/templates/local/文件夹重命名并在上传完成后再进行命名。

注:如果你使用上面的第一种方法的话就不会有这样的问题。--Omrik 2007年5月3日,13:15 (PDT)

添加至页脚[ ]

你可以将Adsense横幅添加到页脚。找到如下代码并将你的Adsense代码添加在其下。

<div id="gsFooter">
	{g->logoButton type="validation"}
	{g->logoButton type="gallery2"}
	{g->logoButton type="gallery2-version"}
	{g->logoButton type="donate"}
</div>
{/if}  {* end of full screen check *}

记住使用

<div align="center"><--ADSENSE CODE--></div>

以将你的横幅居中。

添加至边栏[ ]

这将会在边栏中添加一个120X600的Adsense Skyscraper。

/gallery2/themes/matrix/templates/sidebar.tpl复制到/gallery2/themes/matrix/templates/local/sidebar.tpl,并对刚复制过来的文件进行编辑。

 </div>

之后添加120X600尺寸横幅的Adsense代码。

这将会在你的边栏中显示120X600的横幅并为其应用符合Matrix外观主题的颜色。

Carbon外观主题[ ]

如果你使用carbon外观主题的话,那么你很走运。

启动FTP程序,打开/gallery2/themes/carbon/templates文件夹并找到ads.tpl。将此文件复制到桌面。使用文本编辑器将其打开(如果你的系统是Windows XP就使用记事本)并阅读其中已有的文本。将你的Adsense代码复制其中,并使用{literal} {/literal}标识将其包括进去。将该文件保存为ads.tpl并上传到你的/gallery2/themes/carbon/templates/local文件夹中。

OK,这就成了!

--JDuc2008年2月28日

针对carbon外观主题:在相片视图的缩略图中:

举例

http://www.pho2o.net/gallery/v/deeb/n649780189_136741_6625.jpg.html

打开gallery ftp或cpanel

打开文件管理器并来到gallery文件夹

打开外观主题

打开carbon

打开模板

编辑navigatorMicroThumbs.tpl

在{/if}之后的代码末尾添加adsense代码

我没有对另外的外观主题再做尝试了

ps :我使用的是adesnse 120 X 600

http://pho2o.net



多个广告[ ]

这里还有一个例子说明如何将Google AdSense广告添加到matrix外观主题。我对matrix外观主题做了修改并添加了一个200x200的广告至边栏,一个728x90的横幅及一个180x150的广告到3X3相册/图片显示的中央,这样只有8张图片可见了。所有代码及指导信息可以在此找到:http://wiki.version6.net/matrixad --Cougar 2007年5月28日,08:02 (PDT)

Matrix颜色[ ]

要按照Matrix外观主题颜色的风格创建adsense代码的话,请使用如下各部分的颜色代码:

边界:FFFFFF 标题:6B8CB7 背景:FFFFFF 文本:000000 URL:EEEEEE

相关[ ]

如何向我的Gallery2添加Google Analytics 如何在缩略图行之间添加广告