Jump to content

Typographer


Mike Rockett
 Share

Recommended Posts

Thanks Macrura :)

I actually see that I'm going to need to bump PHP Typography to 6.x first, which means I'll land up bumping the module version to 0.5 for a little testing. Looks like there's been a cleanup and some new features added, as well as a bunch of hyphenation languages. Will open an issue for that shortly.

Link to comment
Share on other sites

  • 2 months later...

Hi,

I currently updating my website, and run with problem with Typographer. I use version 0.4.0 on local 7.0.30-0ubuntu0.16.04.1

Strangely I have this problem only in my home page (other pages seems to work), so I guess it's a specific setting but no idea which one. Can you see it?

Thanks!

Mel

image.thumb.png.37385d3f2ca779974653e30c16f8d596.png

Link to comment
Share on other sites

Hi @Mike Rockett

Sorry, I forgot to mention. I updated last week to the last dev version 3.105. It should be related to either PW version or PHP version, since on my production website, with the same settings and same data, it works fine.

I was able to delimited to a specific part :

Spoiler

$abstracts = $pages->find("template=publication, categ_publi=1108, limit=4, sort=-year, sort=-date_sort"); // abstract

foreach($abstracts as $c) { 
			$congres[$c->congress] = $c;
	}
	
		<h4 class='title is-4'>
	  	<span class='icon is-medium'><i class='fa fa-globe fa-fw' aria-hidden='true'></i></span>  
		{$abstracts->first()->categ_publi->title}s</h4>
			<div class='columns'>";
				foreach($congres as $c) {
					$content .= "<div class='column'><div class='box'>
					<div class='title is-6'><a href='{$c->url}'>{$c->congress}</a></div>
					<div class='columns is-multiline is-inline-mobile is-centered'>
						<div class='column'>
						<span class='icon'><i class='fa fa-calendar fa-fw' aria-hidden='true'></i></span>
						<p class='is-inline-mobile'>{$c->congress_date} {$c->year}</p>
						</div>
						<div class='column'>
						<span class='icon'><i class='fa fa-map-marker fa-fw' aria-hidden='true'></i></span>
						<p class='is-inline-mobile'>{$c->congress_location}</p>
						</div>
					</div></div></div>";
				} 

 

I received error for the "congress field". I tried to change the data or even empty, but it didn't change the error. Even deleting "<div class='title is-6'><a href='{$c->url}'>{$c->congress}</a></div>" doesn't help. Everywhere else in the website where it uses this field, I get the same error.

Thanks!

EDIT: I refine more the issue by comparing my different fields, problematic or not. This field have some <sup></sup> (I export data from a other software, and it's difficult to remove them). Could it be the problem? It wasn't in previous version of PW.

Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

Hi @Mike Rockett, first of all thanks for this wonderful module! Been using this for a while but never stopped by to say thanks.

I just sent two pull requests your way I'd love to get your take on.

The first one makes the module work well with multi-language sites by adding a hook for modifying the Typographer Settings instance.

The second one just updates the underlying php-typography package, while we're at it.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
Posted (edited)
On 10/24/2020 at 2:28 PM, d'Hinnisdaël said:

Hi @Mike Rockett, first of all thanks for this wonderful module! Been using this for a while but never stopped by to say thanks.

I just sent two pull requests your way I'd love to get your take on.

The first one makes the module work well with multi-language sites by adding a hook for modifying the Typographer Settings instance.

The second one just updates the underlying php-typography package, while we're at it.

Hi Phillip – I'm so incredibly sorry for neglecting this. I noted in the merge requests that I'd get to it, and then never did. I'm going to go ahead and accept both and release, however I have no reliable way to test without configuring dev-environments for it. So if there are any issues, we can deal with them on an as-and-when-needed basis.  Edit: Managed to test.

On 4/17/2021 at 11:02 PM, Spiria said:

I have a strange problem which is also present with another fork of php-typography. All the letters are spaced... I had hope that your module would have not the same problem. It seems related to the locale.

Putting set_space_collapse to  false resolves the issue.

2097408623_CleanShot2021-04-17at13_55_55.png.2a4fa1e999ae279ab6f7207b1f5319f2.png

https://github.com/mundschenk-at/php-typography/issues/137

 

On 4/17/2021 at 11:27 PM, Spiria said:

I have however another stranger and more important problem in French. Every "ne" which is the negation in French, is replaced by "né"!!!

1629714648_CleanShot2021-04-17at17_24_27.png.714c3700bdf9bf5ddc599fe3b51d0c5a.png

979890819_CleanShot2021-04-17at17_26_27.png.a98645c078a5902a10337a59123e9a5c.png

Very strange. Seems like something that would need to be fixed in the underlying package. Updating to v6.6 now as part of the above merge request at least. 🙂

Edited by Mike Rockett
  • Like 2
Link to comment
Share on other sites

29 minutes ago, Mike Rockett said:

Very strange. Seems like something that would need to be fixed in the underlying package. Updating to v6.6 now as part of the above merge request at least. 🙂

In fact, switching the diacritic corrections to off in French resolved the problem. "ne" is set to be corrected into "né" when you are in English.

Link to comment
Share on other sites

Ok that seems to have been due to caching - the module system heavily caches frontend pages, which it shouldn't really be doing for pages that require authentication...

Anyways, I have a new problem now. It seems that PW no longer accepts projects that live outside GitHub (it used to, as the current module points to the GitLab repo). @ryan – would it be possible to allow non-GitHub repositories?

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

@Mike Rockett (& others), I think I must be missing something obvious here. Using the standard modules installer, I’ve installed Typographer 1.0.0 into my PW 3.0.179 installation (PHP 7.4.19), and configured many of its options. Two examples: smart quotes and smart ordinals.

Following the example of TextformatterMarkdownExtra (which I have working), I “get” the module:

$typ = $modules->get('TextformatterTypographer');

I then want Typographer to process the contents of a field “vsDetails” (in $item):

$details = $item->vsDetails;
$typ->format($details);
echo "<p class='news'>$details</p>";

All this seems to work without error, but $details is echoed unmodified: foot symbols used as apostrophes remain “'” and “2nd” remains unchanged (the “nd” is not superscripted).

The whole site is in debug mode; Tracy is installed (but I don’t really know how to use it yet). If I make other changes to the page, they’re immediately apparent, so I’m pretty sure caching isn’t an issue. (And just to be sure, I deleted the contents of /site/assets/cache/ )

I see that it’s possible to turn Typographer off for certain elements and classes; the text I’m feeding it is not from any of those, but I’m really not sure how it would know one way or the other. I’m taking this as another sign that I’m missing an important concept.

FWIW, I can run the TextformatterMarkdownExtra module on the same text in the same way, and it works perfectly.

Thanks for any help or pointers you can give!

Link to comment
Share on other sites

@ErikMH – Hi Erik,

The module wasn't intended to be used manually like that. Normally, you would apply the module as a formatter for the field in question by modifying the field's configuration. Under the hood, the formatValue method is called, which imports the vendor packages and runs the formatter. I guess if you wanted to, you could call this method manually, but you would need to pass in an instance of the current page and field. Here is the method signature that it uses:

public function formatValue(Page $page, Field $field, &$value);

The value is passed in by reference.

I guess I can see that there might be use-cases for calling the method outside of the PW field system, so I reckon I should add a method to format arbitrary strings without the page and field dependencies (which are not used anyway - it's just the method signature that PW uses for formatters).

  • Thanks 1
Link to comment
Share on other sites

1.1.0 released with support for formatting text outside of the field context. You can now use the following to format arbitrary text:

print $modules->get('TextformatterTypographer')->formatString($text);

Note that this new method does not use by-reference passing of the input text.

  • Like 2
Link to comment
Share on other sites

Thank you so much for your quick response, @Mike Rockett! Long-time developer here, but very very new to ProcessWire. I’d suspected I was calling the module in the wrong way — and clearly I was right! So, thank you for adding the new method, but in fact I’ll look into configuring the field to use it as a formatter; I’ll bet that’ll be more efficient in terms of caching (and using a reference!) than what I was trying to do!

I’m loving ProcessWire, but there’s a lot to learn....

  • Like 1
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.
  • Similar Content

    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
×
×
  • Create New...