Jump to content


From mediawiki.org
This page is a translated version of the page Manual:Title.php and the translation is 37% complete.

Before 1.40:

The Title class represents page titles.

  • Title implements the following interfaces: LinkTarget , PageIdentity , IDBAccessObject
  • It can be instantiated with one of the factory methods below.
  • Once instantiated, the title can be retrieved in other formats or queried for its attributes. Various non-static accessor methods are available for this, such as getText(), getDBKey(), getNamespace(), etc. Many of these are used by Manual:CoreParserFunctions.php to generate magic words.
  • It is intended to be an immutable "value" class, so there are no mutator functions.[1][2]


Methods for accessing an instance of Title include :

Kaidah ogonop

kaidah Instantiation

To instantiate Title, call one of the static factory methods:

  • Title::newFromDBKey( $key )
  • Title::newFromID( ($id, $flags=0) ). Note that an alternative method, Title::newFromIDs( $ids ), is deprecated in favour of using a PageStore QueryBuilder.
  • Title::newFromText( $text, $defaultNamespace=NS_MAIN )
  • Title::newFromURL( $url ) - This is not the function you want. Use Title::newFromText().
  • Title::makeTitleSafe( $ns, $title, $fragment= '', $interwiki= '') - Wonsoyo Title wagu mantad liwangngaran indeks om kunsi DB. Returns null on an error.
  • Title::newFromRow( $row )
  • Title::newMainPage() - wonsoyo Title wagu montok Bolikan tagayo.


To check and see if a given page already exists:

$titleObject = Title::newFromText( 'Talk:Your desired title here' );
if ( !$titleObject->exists() ) echo "There is no page with that name.";

Pomonsoi Title wagu mantad teks, miagal do nunu okito sosongulun id iso link. Decodes any HTML entities in the text. Spaces, prefixes, and an initial ':' indicating the main namespace are accepted. Note that if the page does not exist, this will not create it. For that, see Manual:Article.php .

Popohompit do uhu bolikan

  • getDBKey() - get the main part (i.e. the title excluding namespace) with underscores.
  • getText() - get the text form (spaces not underscores) of the main part, i.e. the title excluding namespace, but including slashes and everything after. See magic word {{PAGENAME }}.
  • Prefixed with namespace and interwiki prefixes, if any:
    • getPrefixedDBkey() - get the prefixed database key form with underscores.
    • getPrefixedText() - get the prefixed title with spaces. This is the form usually used for display. See magic word {{FULLPAGENAME }}.
      • __toString() - return a string representation of the current title.
    • getFullText() - get the prefixed title with spaces, plus any fragment (i.e. the part beginning with '#').
  • getRootText() - get the root page name text without a namespace, i.e. the leftmost part before any slashes.
  • getRootTitle() - get the root page name title, i.e. the leftmost part before any slashes.
  • getBaseText() -

get the base page name, i.e. the leftmost part excluding namespace and before any slashes (before the subpage name), without converting spaces to underscores. See magic words {{BASEPAGENAME }} and {{BASEPAGENAMEE }}.

  • getBaseTitle() - get the base page name title, i.e. the part before the subpage name.

Relating to page titles (URL-encoded)

URL-encoded titles, not actual URLs:

  • getPrefixedUrl() - get a URL-encoded title, including interwiki. See magic word {{FULLPAGENAMEE }}.
  • getPartialURL() - get the URL-encoded form of the main part. See magic word {{PAGENAMEE }}.
  • getSubpageUrlForm() - get a URL-encoded form of the subpage text. See magic word {{SUBPAGENAMEE }}.

Popohompit do bolikan URL

  • getFullURL() - get a real URL referring to this title, with interwiki link and fragment.
  • getFullUrlForRedirect()
  • getLocalURL() - get a URL with no fragment or server name.
  • getLinkURL()
  • getInternalURL()
  • getCanonicalURL() - get the URL for a canonical link, for use in things like IRC and e-mail notifications. kopomogunoon $wgCanonicalServer om GetCanonicalURL pangawit.
  • getEditURL() - panganu ilo URL idit (miampai action=edit) montok Title diti

Mongintong uhu bolikan

  • equals() - compare by checking if the namespace prefix, title text and interwiki prefix are the same.
  • isSameLinkAs() - similar to equals(), but additionally compares the fragment part. See also LinkTarget::isSameLinkAs() .

Relating to page title fragments

  • getFragment() - get the Title fragment (i.e. the bit after the #) in text form.
  • hasFragment()
  • getFragmentForURL()
  • setFragment()
  • createFragmentTarget() - creates a new Title for a different fragment of the same page.

<span id="Relating_to_namespaces ">

Pohompiton do ngaranliwang

  • getNamespace() - get the namespace index. See {{NAMESPACENUMBER }}.
  • getNamespaceKey() - papalabus kakang di noguno montok xml id kingaran id tag monobuuk.
  • getNsText() - get the namespace text of the page. See magic words {{NAMESPACE }} and {{NAMESPACEE }}.

Montok do pilion suai, intangai NamespaceInfo .

<span id="Relating_to_talk_pages ">

Pohompiton do bolikan mimboros

  • getTalkPageIfDefined() - get a Title object associated with the talk page of the current article if such a talk page can exist. Intangai {{TALKPAGENAME }} om {{TALKPAGENAMEE }}. getTalkPage() is deprecated since 1.34 (in favour of getTalkPageIfDefined).
  • isTalkPage() - Intanai bolikan wagu
  • getTalkNsText() - get the namespace text of the talk page. See magic words {{TALKSPACE }} and {{TALKSPACEE }}.
  • getSubjectNsText() - get the namespace text of the subject (rather than talk) page. See magic words {{SUBJECTSPACE }} and {{SUBJECTSPACEE }}.
  • getSubjectPage() - used to get a title object associated with the subject page of this talk page - is deprecated since 1.34 in favour of NamespaceInfo::getSubjectPage . See also the magic word {{SUBJECTPAGENAME }}.

<span id="Relating_to_categories ">

Pohompiton do kategori

  • getParentCategories() - panganu kategori di kisanganu do Title mamaso.
  • getParentCategoryTree() - panganu do molohing puun kategori.
  • getCategorySortkey() - returns the raw sort key to be used for categories, with the specified prefix. This will be fed to Collation::getSortKey() to get a binary sortkey that can be used for actual sorting.
  • canUseNoindex() - Samaada magic words __INDEX__ om __NOINDEX__ guno do bolikan diti.

<span id="Relating_to_redirects ">

Pohompiton do Kosimbanan atul

  • isRedirect() - Intangai nung artikol nopo nga bolikan nokosimban atul
  • getRedirectsHere() - get all extant redirects to the current Title.
  • isValidRedirectTarget() - Intangai nung Title mamaso nopo nga simban atul poniruan di ohimag.
  • isSingleRevRedirect() - locks the page row and check if this page is single revision redirect.

<span id="Relating_to_subpages ">

Pohompiton do subbolikan

  • getSubpage() - Panganu uhu montok do subbolikan do bolikan mamaso.
  • getSubpageText() - get the lowest-level subpage name, i.e. the rightmost part after any slashes. See magic word {{SUBPAGENAME }}.
  • hasSubpages() - Intanai nung bolikan mamaso haro subbolikan.
  • getSubpages() - Panganu koinsanai subbolikan do bolikan diti.
  • isSubpageOf() - Intanai nung uhu mamaso nopo nga subbolikan do bolikan suai.
  • Intanai nogi: getSubpageUrlForm().

Surupuo miampai odorowot:

  • getLinksTo
  • getTemplateLinksTo()
  • getLinksFrom()
  • getTemplateLinksFrom()
  • getBrokenLinksFrom()

Popohompit do bolikan boros

  • getPageLanguage() - get the language in which the content of this page is written in wikitext. Defaults to content language, but in certain cases it can be e.g. $wgLang (such as special pages, which are in the user language).
  • getPageViewLanguage() - get the language in which the content of this page is written when viewed by user. Defaults to content language, but in certain cases it can be e.g. $wgLang (such as special pages, which are in the user language). Will be deprecated in 1.42 in favour of ParserOutput::getLanguage and see also OutputPage::getContLangForJS .

<span id="Relating_to_page_revisions ,_etc.">

Pohompiton do bolikan sukuan , etc.

  • exists() - intangai nung bolikan koulai
  • isNewPage() - Inganai nung bolikan diti wagu.
  • purgeExpiredRestrictions()
  • estimateRevisionCount() - get the approximate revision count of the current page.
  • getDeletedEditsCount - count archived revisions.
  • hasDeletedEdits() - check if there is a version of the current page in the deletion archive.
  • getEditNotices() - panganu katayadan nutid render idit montok bolikan diti.

Popohompit do page_touched/timestamps :

  • invalidateCache() - koinwoguan page_touched montok do bolikan wagu. Nolohou iti mantad LinksUpdate.php .
  • touchLinks() - update page_touched timestamps and send CDN purge messages for pages linking to this title. May be sent to the job queue depending on the number of links. Kosoruan nopo nga wonsoyo om ugaso.
  • getTouched() - panganu captimpu di notopis wagu

Kohompit do milointangan

  • isAlwaysKnown() - apitanga-au oguno montok ginumuan
  • isKnown() - check if the current Title refers to a page that can (or might) be meaningfully viewed?
  • hasSourceText() - Intanai nung bolikan wagu kiharo teks kowonuan.
  • getDefaultMessageText() - Get the default (plain) message contents for an page that overrides an interface message key.

  • getArticleID() - get the article ID for this Title from the link cache, adding it if necessary. For "internal" articles, it should return the "page_id" field if the article exists, else it returns 0. For all external articles it returns 0. All of the IDs for all instances of Title created during a request are cached, so they can be looked up quickly while rendering wikitext with lots of internal links.
  • resetArticleID() - inject a page ID, reset DB-loaded fields, and clear the link cache for the current Title.
  • clearCaches() - Lidango link cache miampai cance Title.
  • getLatestRevID() - Panganu page_latest gana.
  • getLength() - Panganu do ninaru bolikan.
  • pageCond() - get an associative array for selecting the current Title from the page table.
  • getWikiId()
  • getId() - Manganau do ID bolikan.
  • toPageIdentity() - return the page represented by the current Title as a ProperPageIdentity .
  • toPageRecord() - Gulio' kawagu bolikan nongobi kawawagu iri no Title sabaagi ProperPageRecord .

Momoguno do objek Title

In order to create objects or access data, many methods in other MediaWiki PHP classes depend on the availability of a Title object.

Sabaagi pomitanan, nung haro objek Title nu, milo ko manganu:

  • Article object, using Article::newFromTitle ( $title, IContextSource $context )

This class can fetch various kinds of data from the database; however, it does so inefficiently. Consider using a TitleValue object instead. TitleValue is more lightweight and does not rely on global state or the database.

See also


  1. Mutable is a key word of the norm saying that even a const object can modify this variable. A mutable attribute can be private or public. It can always be modified even when the object is in a constant context.
  2. Mutator is the general name of a member function which can modify one or more object private variables from outside. It is useless to set it private.