SamC Posted October 20, 2017 Share Posted October 20, 2017 1 hour ago, Marudor said: Can I find that code and just cancel Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol Yeah, just change: <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> to: <title><?php echo $page->title; ?></title> ...and from then on the title tag of each page will be exactly what you type in the 'Title' field with nothing more added to it. 1 Link to comment Share on other sites More sharing options...
Marudor Posted October 20, 2017 Author Share Posted October 20, 2017 56 minutes ago, SamC said: Yeah, just change: <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> to: <title><?php echo $page->title; ?></title> ...and from then on the title tag of each page will be exactly what you type in the 'Title' field with nothing more added to it. Ok thank's , I will try that .... Ideally I would like to have something added to the title tag. So the title meta tag would be diiferent that title field and up to 70 characters long. The added text to title field would be exactly the one I would need, different on every page. You see what I am trying to do. I need to have a possibility to have a different title tag than the tilte field on every page (up 70 characters long but not more. Now they are all too long) Link to comment Share on other sites More sharing options...
SamC Posted October 20, 2017 Share Posted October 20, 2017 5 hours ago, Marudor said: Ok thank's , I will try that .... Ideally I would like to have something added to the title tag. So the title meta tag would be diiferent that title field and up to 70 characters long. The added text to title field would be exactly the one I would need, different on every page. You see what I am trying to do. I need to have a possibility to have a different title tag than the tilte field on every page (up 70 characters long but not more. Now they are all too long) You need two fields. 1) Create a new field, call it ''altTitle' (but can be any name). NOTE: if you're copy/pasting then the name must be 'altTitle'. 2) On the field 'Input' tab. Set max length to 70 and add a 'character counter'. 3) Add this field to any templates that need an alternate title. So now, if you want just the 'title' field: <title><?php echo $page->title; ?></title> Or just the 'altTitle' field: <title><?php echo $page->altTitle; ?></title> The 'altTitle' field OR the 'title' (i.e. if the 'altTitle' is empty or not present on the template, then will just print value of 'title'): <title><?php echo $page->get("altTitle|title"); ?></title> The 'title' field with the 'altTitle' appended to it (if 'altTitle' exists on template): <title> <?php echo ($page->altTitle) ? $page->title . " - " . $page->altTitle : $page->title; ?> </title> Good luck 2 Link to comment Share on other sites More sharing options...
Marudor Posted October 23, 2017 Author Share Posted October 23, 2017 On 20.10.2017 at 3:11 PM, SamC said: 2) On the field 'Input' tab. Set max length to 70 and add a 'character counter'. Hi. How can I setup 70 characters in the input tab an how to add character counter? Link to comment Share on other sites More sharing options...
Marudor Posted October 23, 2017 Author Share Posted October 23, 2017 I chose type - TextareaLanguage An I will use this one, Quote <title><?php echo $page->get("altTitle|title"); ?></title> Just that 70 characters setup Link to comment Share on other sites More sharing options...
Marudor Posted October 23, 2017 Author Share Posted October 23, 2017 On 20.10.2017 at 2:23 PM, Marudor said: Yeah, just change: <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> to: <title><?php echo $page->title; ?></title> Hi I have change that to <title><?php echo $page->title; ?></title> in blog-main.inc - the only place with head section I could find. It didn't work . I inherited that site, and I will change it for a wordpress someday but in the meantime I have to fix few things. I added there GoogleAnalytics tag and it's not working either. Link to comment Share on other sites More sharing options...
szabesz Posted October 23, 2017 Share Posted October 23, 2017 6 hours ago, Marudor said: How can I setup 70 characters in the input tab an how to add character counter? Go to: Setup > Fields > altTitle > Input tab: 2 hours ago, Marudor said: in blog-main.inc - the only place with head section I could find. It didn't work . Did you get an error (if yes, what?) or you just did not see any change in the source code of the page? If the latter, did you make sure you are not watching some sort of cache? (browser, cloudflare, ProCache, ProcessWire cache etc...) 2 hours ago, Marudor said: I added there GoogleAnalytics tag and it's not working either. I have no experience with this one but if you are still getting cached pages then it is what makes it hard for you to work on any changes. Seeing how much trouble it means to make changes to the site, you might want to ask for some paid help. Have you considered this? 1 Link to comment Share on other sites More sharing options...
SamC Posted October 23, 2017 Share Posted October 23, 2017 27 minutes ago, szabesz said: I added there GoogleAnalytics tag and it's not working either. Once you add your the tag, it can take 24-48hrs for any results to be seen in the analytics account so you wont know if this is working or not for at least a day. 27 minutes ago, szabesz said: Seeing how much trouble it means to make changes to the site, you might want to ask for some paid help. This is a good suggestion, especially if you're going to change it out for a wordpress site anyway. 1 Link to comment Share on other sites More sharing options...
Marudor Posted October 24, 2017 Author Share Posted October 24, 2017 22 hours ago, szabesz said: Go to: Setup > Fields > altTitle > Input tab: Did you get an error (if yes, what?) or you just did not see any change in the source code of the page? If the latter, did you make sure you are not watching some sort of cache? (browser, cloudflare, ProCache, ProcessWire cache etc...) I have no experience with this one but if you are still getting cached pages then it is what makes it hard for you to work on any changes. Seeing how much trouble it means to make changes to the site, you might want to ask for some paid help. Have you considered this? Id dit not get any error. It just did't change a thing i swaped <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> for <title><?php echo $page->title; ?></title> In the code of the file where head section is - in my case - blog-main.inc . And no change .... the meta tag title is still with the suffix that comes from the home page : Employer branding - pracownik staje się klientem - Agencja PR Q&A Communications – Poznań, Warszawa And no this is no cache. The other thing is that my input tab in the field edditng panel looks different... There is no minimum or maximum field there.... Link to comment Share on other sites More sharing options...
Mont Posted October 24, 2017 Share Posted October 24, 2017 A great example of what you are trying to achieve is in the site profile called Blue VR. I would recommend you install on a test server or dev folder. It has fields for meta keywords and meta descriptions for each page. Then go to your cpanel or plesk panel and browse to the template files located at public_html/site/templates/ and see how the fields are in the _done.php file. I came from Joomla and had to learn more to use Processwire and am better for it. Good luck! Link to comment Share on other sites More sharing options...
szabesz Posted October 24, 2017 Share Posted October 24, 2017 5 hours ago, Marudor said: In the code of the file where head section is - in my case - blog-main.inc . And no change The home page has page ID 1, so if($page->id > 1) { echo $page->title .' - '; } means that the page's Title is only prepended to it if it is not the home page. But you remove it altogether so echo $page->title; must spit out the value of the Title field no matter what. 5 hours ago, Marudor said: The other thing is that my input tab in the field edditng panel looks different... There is no minimum or maximum field there.... In the screenshot I can see that it is a ProcessWire 2.7.3 site. I started with ProcessWire 3.x beta so I'm jut guessing here but probably this feature has been added later. Similar behavior can be achieved with a hook like this: https://github.com/processwire/processwire-requests/issues/124#issuecomment-337139081 and in your case it should look like this: <?php $wire->addHookAfter('InputfieldTextarea::render', function(HookEvent $event) { $inputfield = $event->object; $out = $event->return; if($inputfield->hasField != 'altTitle') return; if(strlen($inputfield->value) > 70) { $alert_text = "The length of this field is greater than 70 characters!"; $event->return = "<p style='color: red;'>$alert_text</p>" . $out; } }); this hook goes into /site/ready.php (if you do not have one just create this PHP file) and it is just a warning, not a validator. Also, the message only appears after saving the page. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now