douqin231881 2012-06-22 09:23
浏览 90
已采纳

vBulletin模板中对论坛徽标的更改

The title of my question may be unclear, so let me explain what's the problem I'm facing.

I'm new to vBulletin system, but I have some work to do on an existing forum. The given forum has a logo on the top header. The forum should be accessible from different domains which are locale based, and in each case the logo must be different.

As I figured it out, the vBulletin system holds all it's templates in the DB (a table called "template"). I found the line with the header content, where the logo is inserted. It looks like this:

$final_rendered = '<div class="above_body"> <!-- closing tag is in template navbar -->
<div id="header" class="floatcontainer doc_header">
    ' . ''; 
if (vB_Template_Runtime::fetchStylevar('titleimage')) {
   $final_rendered .= '<div><a name="top" href="' . vB_Template_Runtime::linkBuild("forumhome") . '" 
     class="logo-image"><img src="' . vB_Template_Runtime::fetchStylevar("titleimage") . '" 
     alt="' . vB_Template_Runtime::parsePhrase("x_powered_by_vbulletin", '' . $vboptions['bbtitle'] . '') . '" /></a></div>';
} else {
    $final_rendered .= '';
}
 ...

The key part here is src="' . vB_Template_Runtime::fetchStylevar("titleimage") . '" which actually sets the image source. The source itself is held in the DB again and is set in the admin tool of vBulletin. Now what I need is to change the source according to the domain.

I know of course hoe to do that, but I'm not sure where to do that. I think it's not right to do changes in the DB manually. As I understood, the system generates each page template using these DB rows, so I might better do some changes in the place it is done?

The thing is, I cant find the right place where the actual templates are constructed, or the place where these lines from DB are first loaded.

Can anyone give me a clue where or how to achieve this?

Note that I need to make changes not only to the header image, but also to some other tings in footer, sidebar, etc... So it would be better to find some final "variable" or something and make changes to it by just replacing strings.

The solution doesn't need to be a perfect idea, just a rough and fast one will be satisfying...

  • 写回答

2条回答 默认 最新

  • dongluolie3487 2012-07-07 04:50
    关注

    Create a plugin that uses the "global_bootstrap_init_start" hook so it will be available in the various areas you need.

    Have the plugin determine which domain is serving the page and then set a global variable that you can check wherever you need it. Put something like this in your plugin:

    $GLOBALS[yourDomainNameVariable] = "yourKeywordForParticularDomain";

    Intersting discussion here: HTTP_HOST vs. SERVER_NAME


    You'll need to to modify each template that has an item you want to change based on the domain. If you have a distinct ID, class, etc. from looking at the HTML source, the easy way to find and update the template is this:
    Admin Control Panel -> Styles and Templates -> Search in Templates

    I tried searching for "<div class="above_body">" and found the header template quickly. Here's the code for the image:

    `<img src="{vb:stylevar titleimage}" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" />`
    

    It seems like the easiest thing would be to have a separate folder with the images for each domain and use the same name for each image across the domains. Then you can replace the default image path with yours. For example:

    `<img src="/images/{vb:raw GLOBALS.yourDomainNameVariable}/title.png" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" />`
    

    I just looked closely at the code you posted and I suspect that you're working with vBulletin 3.x. I'm guessing because I've only worked with 4.x. I'm not sure how much if any of what I've written will be of use to you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式