Jump to content

Setting page title from other page title with apostrophe (single quote)


Recommended Posts

Hi there,

I am creating a system where there is a sort of "template" page that contains details about a particular quiz, and then a user account gets a record page created and associated with their account that contains specific details about their particular progress for that quiz, their status for that quiz, etc. I have the following code in a module to create this copy page:

$quizPage = $this->pages->get("template=quiz, id=$quizID");
$record = new Page();
$record->template = $this->templates->get('quiz-record');
$record->parent = $parentPage;
$record->title = $quizPage->title;
$record->name = $quizPage->name;
$record->linked_quiz = $quizPage->id;
$record->owner = $userid;

(Omitted unnecessary quiz details for this issue)

Where $quizPage is the template page containing quiz details (questions, etc.), and $parentPage is the container page to hold all of a particular user's records.

When I try to set the title of the new page using $quizPage->title as the value, if the source page has a single quote in it, for instance... if the title was People's Choice, the new page has the HTML Entity entered as the page title, so the title becomes People's Choice for the new page.

I've tried outputting the raw title to see if it's stored as an HTML entity, and even checked the database value directly, but it definitely is just a single quote. Is there any way to get the new page's title to contain a Single Quote rather than the entity value?


Link to comment
Share on other sites

The HTML Entity Encoder is probably applied to the title field (which is good). So you need to turn off output formatting for $quizPage...


...or at least get the unformatted value of the title field...

$record->title = $quizPage->getUnformatted('title');


  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...