Jump to content

How can i remove part of a title?


zc5

Recommended Posts

I am still a novice with PHP but I feel like I am making this task more complicated then it needs to be. 

 

I recently acquired a tool (dumpHTML) that is coded in php which allows me to convert mediawiki content into html. I have been trying to make minor changes to it so it looks more clean after i convert to html. All the titles of my pages end with " - Docwiki" (Example: "Hole Mounts - Docwiki") and i do not like that. I want to write something that deletes the " - Docwiki" at the end of every title once i use the conversion tool. 

 

Here is the original code line:

 

<title><?php $this->text('pagetitle') ?></title>

 

 

Here is what I have attempted and i get a fatal error when i try to run the tool:

 

 <?php
$pagetitleA=text('pagetitle');
chop($pagetitleA, " - Docwiki");
?>
<title><?php $this->$pagetitleA ?></title>
 
 
Is there something I am missing or doing completely wrong? Any help or suggestions will be greatly appreciated!
Link to comment
https://forums.phpfreaks.com/topic/279643-how-can-i-remove-part-of-a-title/
Share on other sites

Yes, of course. This is code from the tool i use, I did not write this myself although im trying to make some edits. I barely understand half of it :) but thank you though! 

<head>
    <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
	<!-- headlinks removed -->
	<link rel="shortcut icon" href="<?php $this->text('favicon'); ?>"/>
    <title><?php $this->text('pagetitle') ?></title>
    <style type="text/css">/*<![CDATA[*/ @import "<?php $this->text('skinpath') ?>/main.css"; /*]]>*/</style>
    <link rel="stylesheet" type="text/css" media="print" href="<?php $this->text('stylepath') ?>/common/commonPrint.css" />
	<link rel="stylesheet" type="text/css" href="<?php $this->text('stylepath') ?>/common/shared.css" />
    <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
    <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
    <!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
    <!--[if IE 7]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE70Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]-->
    <!--[if lt IE 7]><?php if( in_array( 'IE', $skin->cssfiles ) ) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion']; } ?>"></script>
    <!--[if IE]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
    <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
    <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/jquery.js"></script>
	<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"></script>
	<link rel="stylesheet" type="text/css" media="print" href="<?php $this->text('skinpath') ?>/NavContent.css" />
	<link rel="stylesheet" type="text/css" media="print" href="<?php $this->text('skinpath') ?>/CategoryTree.css" />
	<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/NavContent.js"></script>
	<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/CategoryTree.js"></script>
    <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/md5.js"></script>
    <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/utf8.js"></script>
    <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/lookup.js"></script>
    <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('skinpath' ) ?>/highlight.js"></script>
    <?php if($this->data['jsvarurl'  ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl'  ) ?>"></script><?php } ?>
    <?php if($this->data['pagecss'   ]) { ?><style type="text/css"><?php              $this->html('pagecss'   ) ?></style><?php    } ?>
    <?php if($this->data['usercss'   ]) { ?><style type="text/css"><?php              $this->html('usercss'   ) ?></style><?php    } ?>
    <?php if($this->data['userjs'    ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs'    ) ?>"></script><?php } ?>
    <?php if($this->data['userjsprev']) { ?><script type="<?php $this->text('jsmimetype') ?>"><?php      $this->html('userjsprev') ?></script><?php   } ?>
	<style type="text/css">.highlight { background: #FFFF40; }</style>
  </head> 

Line where i want to edit is line 5. I hope i didn't give more then necessary. :)

Ya i have tried to find where the "pagetitle" is coming from and i can't seem to find it.... i can try again if you think that is the main source of the problem. I know somewhere 'pagetitle' is just simply using the mediawiki pagetitle, but i can't seem to find where so i was hoping to alter it after the fact

O ok I understand. My apologies 

<head>
    <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
	<!-- headlinks removed -->
	<link rel="shortcut icon" href="<?php $this->text('favicon'); ?>"/>
    <title><?php echo str_replace(" - Docwiki",'',$this->text('pagetitle')); ?></title>
    <style type="text/css">/*<![CDATA[*/ @import "<?php $this->text('skinpath') ?>/main.css";
	body { font-size:small; }  /*]]>*/</style>
    <link rel="stylesheet" type="text/css" media="print" href="<?php $this->text('stylepath') ?>/common/commonPrint.css" />
    <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
    <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
    <!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
    <!--[if IE]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
    <meta http-equiv="imagetoolbar" content="no" /><![endif]-->

All i did was replace the two lines:

<title><?php echo str_replace(" - Docwiki",'',$this->text('pagetitle')); ?></title>
 <title><?php $this->text('pagetitle') ?></title>

Is this what you wanted? :)

Well it would be best to look through the class and find the text() function to see how to modify it, but quick and dirty this should work.

Replace:

<title><?php $this->text('pagetitle') ?></title>

With:

<title><?php ob_start(); $this->text('pagetitle'); echo str_replace(" - Docwiki", "", ob_get_clean()); ?></title>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.