Jump to content

new page character problem after save


kkalgidim
 Share

Recommended Posts

echo title;  Output -> Murat Övünç Konseri

After i save page title become like this on admin panel -> Murat Övünç Konseri

 

Here the code i save page

					$p = new Page(); // create a new page 
					$p->template = 'home'; // choose template 
					$p->parent = wire('pages')->get('/posts/'); // choose parent page 
					$p->name = $wire->sanitizer->text($baslik[1]); 
					$p->title = $wire->sanitizer->text($baslik[1]);  
					$p->save(); // save the page

Its multilanguage profile template

ı attached the admin panel output

what should i do?

 

Untitled-4.jpg

Link to comment
Share on other sites

5 hours ago, kkalgidim said:

After i save page title become like this on admin panel -> Murat Övünç Konseri

This means that the value you are saving to the title field has had its special characters converted to HTML entities. You don't want this because the PW admin automatically applies htmlspecialchars() to the title and so the entities are being double-encoded.

So if $baslik[1] is being entity encoded somewhere in your code then simply don't do this step, or if you are getting the value from somewhere where the value is already entity encoded then you can use html_entity_decode() or instruct $sanitizer->text to convert entities:

$p->title = $wire->sanitizer->text($baslik[1], ['convertEntities' => true]);

 

  • Like 5
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
 Share

  • Recently Browsing   0 members

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