View Single Post
Old 09-14-2012, 09:32 AM   #25
GRiker
Comparer of the Ephemeris
GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.
 
Posts: 1,497
Karma: 424627
Join Date: Mar 2009
Device: iPad
Here's a simpler way to test the template before using it in a plugboard.

Create the template function to return a substitute title for Catalogs:
  1. Open Preferences|Advanced|Template Functions
  2. In the Function field, type change_title_if_catalog
  3. Set Arg count to -1
  4. Copy and paste the following code into the Program Code field:
    Code:
    def evaluate(self, formatter, kwargs, mi, locals):
        for tag in kwargs.get('tags'):
            if tag == "Catalog":
                return "0-calibre"
        return mi.get('title')
    You can change 0-calibre to whatever title you'd prefer.
  5. Click Create
  6. Click Apply to close the Template Functions dialog
Create a custom column to display the results of the template:
  1. Open Preferences|Interface|Add your own columns
  2. Click Add custom column
  3. Lookup name: template_test
  4. Column heading: Template test
  5. Column type: Column built from other columns
  6. Template: program: change_title_if_catalog()
  7. Click OK, Apply, then exit and restart calibre
  8. Drag the Template test column next to the Tags column so you can see the results

In the Template test column, you should see either the Title of the book, or 0-calibre if the book has a 'Catalog' tag.

Once you have that working, you can create a plugboard for saving to disk or sending to a specific device.

G

Last edited by GRiker; 09-15-2012 at 04:33 PM.
GRiker is offline   Reply With Quote