Creating Directory - Showing Listing Count on All Directory Pages

Hi to all InDesign Scripters
I am currently creating a directory with InDesign CS6, which contains the name of the person, address, cities, etc.
I have a question which is about showing the listing count per city,
for example, there are 30 names under a city (across spreads and pages),
how to show the number of listing count on InDesign automatically?
And how to make InDesign pick up what numebrs to use on that page?
(If I have two pages should show total listing count under the same city is 30)
I found a script to add sequential # to the paragraph styles, however I was only able to pick up the last number on the page using text variable -Running Headers function in InDesign, not the last number under the same city.
Any help would be appreciated!
Best Regards
V

Hi V,
I looked at the file you attached.
You first need to remove the text boxes that you put in which contain "Total Listings:" in them.
You can run this to do that
var  doc = app.activeDocument,
            finds, l;
app.changeGrepPreferences = app.findGrepPreferences = null;
app.findGrepPreferences .findWhat = "\\ATotal Listings:\\s*\\Z";
app.doScript("addListingsCount()", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Add Listings Count");
function addListingsCount () {
    finds = doc.findGrep();
    l = finds.length;
    while (l--) finds[l].parentTextFrames[0].remove();
After you've removed those frames run the below script and it should work for your document.
// City Listings Count Script by Trevor www.creative-scripts.com (Coming soonish)
// Trevor {at} creative-scripts {dot} com
// http://forums.adobe.com/message/5837823#5837823
    var  doc = app.activeDocument,
            cityCharacterStyle = doc.characterStyles.itemByName ("City"), // Change to correct paragraphStyles name
            nameParagraphStyle = doc.paragraphStyles.itemByName ("Entry Name"), // Change to correct paragraphStyles name
            countParagraphStyle = doc.paragraphStyles.itemByName ("Entries Count"), // Change to correct paragraphStyles name
            cityFinds = [],
            entryFinds = {};
    // Get GeometricBound for Title Text Frames
    var   pageMargins = [], pageGeos = [], textFrameGeos = [],
             vp = doc.viewPreferences.verticalMeasurementUnits,
             distanceFromTopMarginToTheTopOfTheEntriesCountTextFrame = UnitValue ("23.625pt").as(vp);  // Change distance as needed
             heigtOfTheEntriesCountTextFrame = UnitValue (".5cm").as(vp);  // Change height as needed
             widthOfTheEntriesCountTextFrame = UnitValue ("153.75pt").as(vp);  // Change width as needed
             pageWidth = doc.pages[0].bounds[3];
    app.changeTextPreferences = app.findTextPreferences = null;
    app.findTextPreferences.appliedCharacterStyle = cityCharacterStyle; // keep grep set out of fast entire undo mode for safety reasons
app.doScript("addListingsCount()", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Add Listings Count");
function addListingsCount () {
    pageMargins[0] = doc.pages[0].marginPreferences;
    textFrameGeos[0] = [];
    textFrameGeos[0][0] = pageMargins[0].top - distanceFromTopMarginToTheTopOfTheEntriesCountTextFrame;
    textFrameGeos[0][1] = pageWidth - pageMargins[0].right - widthOfTheEntriesCountTextFrame;
    textFrameGeos[0][2] = textFrameGeos[0][0] + heigtOfTheEntriesCountTextFrame;
    textFrameGeos[0][3] = pageWidth - pageMargins[0].right;
    pageMargins[1] = doc.pages[1].marginPreferences;
    textFrameGeos[1] = [];
    textFrameGeos[1][0] = pageMargins[1].top - distanceFromTopMarginToTheTopOfTheEntriesCountTextFrame;
    textFrameGeos[1][1] = pageWidth*2 - pageMargins[1].right - widthOfTheEntriesCountTextFrame;
    textFrameGeos[1][2] = textFrameGeos[1][0] + heigtOfTheEntriesCountTextFrame;
    textFrameGeos[1][3] = pageWidth*2 - pageMargins[0].right;
    cityFinds = doc.pages.everyItem().textFrames.everyItem().findText();
    var l = cityFinds.length,
          c = 0, nameFinds, pageOffsets = [], pageOffset, fl, city, firstFind, n=0, theCities = [];
    while (l > c++) {
        nameFinds = ([]).concat.apply ([],cityFinds[c]);
        if (!(fl = nameFinds.length)) {continue;}
        firstFind = nameFinds[0];
        pageOffset = firstFind.parentTextFrames[0].parentPage.documentOffset;
        theCities[n] = city = firstFind.contents;
        pageOffsets [n++] = pageOffset;
        entryFinds [city] = (entryFinds [city]) ? entryFinds [city] + fl : fl;
    while (n--) {doc.pages[pageOffsets[n]]
                          .textFrames.add ({
                               geometricBounds: textFrameGeos [((pageOffsets[n] !=0) + pageOffsets[n]) % 2],
                               contents: "Total Listings: " + entryFinds [theCities[n]],
                               name: "Listings Count"
    doc.textFrames.itemByName ("Listings Count").isValid && doc.pages.everyItem().textFrames.itemByName ("Listings Count").texts[0].appliedParagraphStyle = countParagraphStyle; // keep isValid && out of fast entire undo mode for safety reasons
// Note if you ever want to remove these text frame you can do
// app.activeDocument.pages.everyItem().textFrames.itemByName ("Listings Count").remove()

Similar Messages

  • How to create a dropdown list to list the values from two different tables?

    Hi,
    I have the following requirement:
    1. I have to create a dropdown list to display all the values from the second column of  a table.
    2. Another dropdown list to display all the values from the second column of another table.
    3. A text box should help me to add the selected values.
    How to get this done in a PDF? Please help.
    Regards,
    Latha

    Is this a LC form? Because Acrobat forms have no concept of tables, just
    individual fields...

  • Create a metric to count on Item Number begining with 9 or 7

    I need to create a metric that counts on all Pay Item Numbers that begin with 9 or 7

    CASE WHEN metric LIKE '9%' OR metric LIKE '7%' THEN 1 END
    you might need to cast it as char and metric's aggregation must be set to Sum

  • How to populate a sharepoint 2010 list from the active directory. How to populate a sharepoint 2010 list with all sharepoint user profiles

    How to populate a sharepoint 2010 from the active directory.
    I want a list of all the computers in the active directory,
    another one with all users.
    I want also to populate a sharepoint 2010 list from the sharepoint user profiles.
    Thanks
    sz

    While
    the contacts list is usually filled out for contacts that are outside the company, there are times when you would use a contacts list to store internal and external resources.  Wouldn’t it be nice if you didn’t have to re-type your internal contacts’
    information that are already in the system?  Now you can with a little InfoPath customization on the contacts list. 
    Here’s our plan:
    Create the contacts list, and open in InfoPath
    Create a data connection to the User Profile web service
    Customize the form adding some text, a people picker and a button
    Create InfoPath rules that will populate the contact fields from the user fields in the User Profile store
    Let’s get going!  Before we begin, make sure you have InfoPath 2010 installed locally on your computer.  I also want to give credit Laura
    Rogers and Darvish Shadravan’s book Using
    Microsoft InfoPath 2010 with Microsoft SharePoint 2010 Step by Step.  I know it looks like a lot of steps, but it’s easy once you get the hang of it.
    So obviously we need a contacts list.  If you don’t already have one, go to the SharePoint site where it will live, and create a contacts list.
    From the list, click the List tab on the ribbon, then click Customize form:
    So now we have our form open in InfoPath 2010.  Let’s add our elements to the form. 
    Above all the fields, let’s add some text instructing users what to do with the the field we’re about to add (.e.g To enter an existing user’s information, choose the user below).
    Insert a people picker control by clicking the Person/Group Picker control in the Controls section of the ribbon.  This will add a column to the contacts list called group.
    Below the people picker, insert a button control from the same section of the ribbon as above.  With the button still highlighted, click the Control Tools|Properties tab on the ribbon. 
    Then in the Label box, change the text to something more appropriate to our task (e.g. Click here to load user data!).
    You can drag the button control a little larger to account for the text.
    We should end up with something like this:
    Before we can populate the fields with user data, we need to create a connection to the User Profile Service.
    Add a data connection to the User Profile Service
    Click the Data tab on the ribbon, and click the option From Web Service, and From SOAP Web Service.
    For the location, enter the URL of your SharePoint site in the following format – http://<site url>/_vti_bin/UserProfileService.asmx?WSDL.  Click Next.
    Note - for the URL, it can be any SharePoint site URL, not just to the site where your list is.
    For the operation, choose GetUserProfileByName.  Click Next.
    Click Next on the next two screens.
    On the final screen, uncheck the box for “Automatically retrieve data when form is opened”. This is because we are going to retrieve the data when the button is clicked, also for performance reasons.
    Now we need to wire up the actions on our button to populate the fields with the information for the user in the people picker control.
    Tell the form to read the user from the people picker control
    Click the Home tab on the ribbon.
    Click the button control we created, and under the Rules section of the ribbon, click Manage Rules. Notice the pane appear on the far right.
    In the Rules pane, click New –> Action. Change the name to something like “Query and load user data”.
    Leave the condition to default (none – rule runs when button is clicked).
    Click the Add button next to “Run these actions:”, and choose “Set a field’s value”.
    For Field, click the button on the right to load the select a field dialog.  Click the Show advanced view on the bottom.  At the top, click the drop down and choose the GetUserProfileByName
    (Secondary) option.  Expand myFields and queryFields to the last option and highlightAccountName.  Click ok. 
    For Value, click the formula icon. On the formula screen, click the Insert Field or Group button. Again click the show advanced view link, but this time leave the data
    connection as Main. Expand dataFields, then mySharePointListItem_RW.  At the bottom you should see a folder called group (the people picker control we just added to the form).  Expand this, then pc:Person,
    and highlightAccountId.  Click Ok twice to get back to the Rules pane.
    If we didn’t do this and just queried the user profile service, it would load the data of the currently logged in user.  So we need to tell the form what user to load the data for.  We take the AccountID field from the people
    picker control and inject into the AccountName query field of the User Profile Service data connection. 
    Load the user profile service information for the chosen user
    Click the Add button next to “Run these actions:”, and choose Query for data.
    In the popup, for Data connection, click the one we created earlier – GetUserProfileByName and clickOk.
    We’re closing in on our goal.  Let’s see our progress.  We should see something like this:
    Now that we have the user’s data read into the form, we can populate the fields in the contact form.  The number of steps to complete will depend on how many fields you want to populate.  We need to add an action step for
    each field.  I’ll show you one example and then you will just repeat the steps for the other fields.  Let’s update the Job Title field.
    Populate the contact form fields with existing user’s data
    Click the Add button next to “Run these actions:”, and choose “Set a field’s value”.
    For Field, click the button on the right to load the select a field dialog.  Highlight the field Job Title.
    For Value, click the formula icon. On the formula screen, click the Insert Field or Group button.  Click the Show advanced view on the bottom. At the top, click the
    drop down and choose theGetUserProfileByName (Secondary) option.  Expand the fields all the way down until you see the Value field.  Highlight it but don’t click ok, but click the Filter
    Data button, then Add. 
    For the first dropdown that says Value, choose Select a field or group.   The value field will be highlighted, but click the field Name field
    under PropertyData.  Click Ok. 
    In the blank field after “is equal to”, click in the box and choose Type text.  Then type the text Title. 
    Click ok until you get back to the Manage Rules pane.  The last previous screen will look like this.
    We’re going to update common fields that are in the user’s profile, and likely from Active Directory.  You can update fields like first and last name, company, mobile and work phone number, etc.  For the other fields, the
    steps are the same except the Field you choose to update from the form, and the very last step where you enter the text will change.  Here’s what the rules look like when we’re done:
    We’re all done, good work!  You can preview the form and try it now.  Click Ctrl+Shift+B to preview the form.  Once you’re satisfied, you can publish the form back to the library.  Click File –> Quick
    Publish.  Once it’s done, you will get confirmation:
    Now open your form in SharePoint.  From the contact list, click Add new item.  Type in a name, and click the button and watch the magic happen!

  • TS3991 I organazied my contacts by the address of my tenants. I just joined to Icloud and I am not able to find my tenants in the directory in the computer at all. I could search when I am using my phone but they do not show at first.how can correct this?

    I am a landlord and I organazied my contacts by the address of my tenants. I just joined to Icloud and I am not able to find my tenants in the directory in the computer at all. I could search when I am using my phone but they do not show at first.how can correct this? as an example 37 31 1 and when i type this nothing is showing.

    I am a landlord and I organazied my contacts by the address of my tenants. I just joined to Icloud and I am not able to find my tenants in the directory in the computer at all. I could search when I am using my phone but they do not show at first.how can correct this? as an example 37 31 1 and when i type this nothing is showing.

  • Plsql utility to traverse directory to list all the files

    Hi All?
    Anybody know of anyway to traverse a directory and list the files under that directory?
    Thanks
    Rgds
    Ung

    Do you want the directory and files on the server or
    the client?On the server.

  • After uploading, template is gone and only parent directory shows

    I'm using Dreamweaver CS4 and uploading to Yahoo for my website. When I try to use the preview in browser, the page shows as blank, and when I upload, only the parent directory shows. How can I fix this?
    The website is: http://www.optimumtx.com/
    Thank you for your time

    Uhmmm... It looks like you haven't named your default starting page correctly - Yahoo hosting is looking for "home.html" to start from and you currently don't have any document titled that. And seeing your list of files (based on your link you supplied) you also have index.dwt up on the server. The .dwt file extension means it's a template! That's only useful in Dreamweaver to create new pages from and has no business being up on your server. Fix that start page issue and you'll most likely resolve the majority of your issues.

  • Apple TV Showing imported movies in podcast directory

    When I am working on a video project at the end of the day I export my rough cuts to an mp4 format then import to my iphone through Itunes to watch and make notes on during the commute home. Sometimes I can watch on my laptop by usually there is no room so my iphone gets more use. When I get home and try to watch the video through my AppleTV, the files are listed correctly in the movies directory and works great.
    The issues is when I then enter my podcast directory through Apple TV, all the video files I imported are also there but listed as unknown. So I will have a listing Diggnation, TRS, then 80 files of unkown. You can watch the file and everything in that regards works.
    How can I prevent the mp4 files I import from showing up in my podcast directory?

    are they also showing up in the podcasts section of itunes ?
    it's possible that it is a tagging issue, check what the "video type" of the file(s) are.

  • Is there a way to create a new directory or file in application install directory programatically

    Hi to all,
    Is there a way to create a new directory or file in
    application install directory programatically.
    I want a xml file to be created with in the application
    install directory programatically(not the application storage
    directory)
    I have used the following code snippet:
    var file:File = new File();
    file = File.applicationDirectory;
    file = file.resolvePath("assets");
    if(!file.exists)
    file.createDirectory()
    I am thrown an exception when using this .....Security
    Exception

    Thanks, but my main problem is to delete the locally stored
    data that is stored in the application storage directory when the
    application is uninstalled.
    The data is not being deleted automatically when the
    application is uninstalled, thats why I want to write some file to
    application directory.
    My application is remembering the login username and password
    even I uninstall the application and reinstall the next
    time.

  • Inbox and Drafts show unread message count of all folders within. Can I get the local folders to do this too?

    I'm filtering mail into folders in the local folder tree. There may be two or three levels, e.g., Local Folders -> Lists -> OS -> MacOSX. Mail that is unread in the MacOSX folder is counted and displayed when the MacOSX folder is visible. However, keeping the entire tree on display is a nuisance and it is long, so I don't see things ate the bottom. I have to scroll to reveal the rest of the items in the folder tree. For these reasons I'd prefer to have the folder tree in its minimal state.
    Is it possible to have the the top level folders display an unread message count for all the enclosed folders?

    when I collapse the folder tree of local folders, it shows the unread count for sub folders.

  • How can I get file list for a given directory?

    Hi,
    How can I get file list for a given directory? Is there a function?
    Thanks.

    Hi friend,
    Try this sample report. It displays all files in a directory.
    While executing give some directory name in input. ex:  C:\
    Mention file type in filter parameter. ex: *.DOC
    REPORT ztests.
    DATA : file_table LIKE TABLE OF sdokpath WITH HEADER LINE .
    DATA : dir_table LIKE TABLE OF sdokpath WITH HEADER LINE .
    PARAMETERS:p_dir(50) TYPE c.
    CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
      EXPORTING
        directory  = p_dir
        filter     = '*.DOC'
      TABLES
        file_table = file_table
        dir_table  = dir_table
      EXCEPTIONS
        cntl_error = 1
        OTHERS     = 2.
    LOOP AT file_table .
      WRITE:/ file_table-pathname.
    ENDLOOP.
    Might be helpful...
    Thanks.....
    Edited by: Guest77 on Feb 11, 2009 5:30 AM

  • Cannot remove an assigned download from downloads list even though its directory does not exist anymore

    I have this download item in my Downloads window. The problem is that it has hung around there without any certain directory anymore. All the options at right-click menu would not take effect--except for 'Open Containing Folder' which is not available. I have a strong confidence that download is registered somewhere in Firefox that might be resolved manually.

    You can try to delete the downloads.sqlite file to clear up the download history.
    * http://kb.mozillazine.org/Unable_to_save_or_download_files#Manually_delete_download_history
    You can use this button to go to the Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder

  • How to List files in a directory into an Array

    Does anyone know of the best way to load all of the files in a specified directory into an array. (not going into sub directories either).
    I was to be able to do something like this.... (pseudo)
    String directory = "C:\";
    String [] theList;
    do
    get next file name;
    add to theList;
    }while(!End of Directory)
    Done.

        public static void main(String args[]) {
         String directory = "C:\\";
         File dir = new File(directory);
         File [] theList = dir.listFiles();
         for(File file : theList)
             if(!file.isDirectory() && !file.isFile())
              System.out.println(file.getName());
         }This will list every item in the coot of C:\ that is not a file or a directory. Change the if statement to fit your needs.
    ~Tim

  • Won't Publish: Get "Directory Listing Denied" "This Virtual Directory does

    ...does not allow contents to be listed." I have no idea what is happening or what this means; the pages look great in iWeb, it seems to be publishing successfully and...NADA. Very frustrating. Please enlighten. You can look for yourself by going to www.thesandsoftime.net. Nothing comes up. My MobileMe is current, it shows in my MobileMe account as my personal domain to be published. Is the problem that I just transferred my domain name to MobileMe (from www.gate.com) earlier tonight and it needs 48 hours to effect this? Or...has it already done what it should do and is flawed? I really would like to get my site up...

    Thanks for the input; it DOES seem the problem was the other place not changing the CNAME...HOWEVER...on my 5 pages created on iWeb and uploaded to my domain name, they LOAD, but only seems to navigate three of them...i.e. you bring up my "Welcome" page, and can click "About Me" page, and maybe one more (even though they all seem to be "highlighted" when you drag the cursor over them)....however, at least 50% of the time, you can't "back" navigate to one of the other pages (i.e., if you've loaded three in a row, it STOPS and you have to use the actual BACK ARROW to try again, which sometimes lets you see all the pages. I feel they haven't loaded correctly, or...????? something? my site is www.thesandsoftime.net if you want to look for yourselves...Help!?!

  • Creating a text file in an oracle directory

    Hello all,
    I created a directory in oracle called sampledata (create directory sampledata as 'c:sampledata'). How do I create a new text file in that directory? That's it.
    Thanks,
    Ad

    I created a directory in oracle called sampledataYou mean you created with sys, right? I think only sys can create directories. Make sure you grant privileges to your user. So let's walk trough this:
    connect sys@orcl as sysdba;
    create or replace directory temp_directory as 'c:\temp';
    grant read, write on directory temp_directory to scott;
    connect scott@orcl;
    declare
      output_file utl_file.file_type;
    begin
        output_file := utl_file.fopen('DIR_TEMP', 'test_file.txt', 'w');
        utl_file.put_line(f, 'Testing output file');
        utl_file.fclose(output_file);
    end;
    /hth,
    gleisson henrique
    I granted priveleges to a different directory that I created. Take a look here:
    http://www.adp-gmbh.ch/ora/sql/create_directory.html
    Pretty good examples.
    Message was edited by:
    Gleisson Henrique

Maybe you are looking for

  • How do I isolate vocals and guitar to their specific microphones?

    Hi, not a very good title so I will try to exlplain further here. I am using Audition CS6 with multiple mic inputs, 2 mics to be precise, 1 to pick up acoustic guitar and 1 to pick up the vocals. I am then using multi-track mode and assiging each mic

  • Scheduling a report in WebI

    Under the Recurrence tab, when selecting a date range the date appears in DD/MM/YYYY format. How is the default changed to reflect MM/DD/YYYY. Another issue is that the description is Date and Time and the fields are reversed as Time Date.  Thanks

  • Weblogic Connection with Oracle JMS AQ errors

    Hi All, I am a newbie with SOA 11g and I am trying to do a simple test case for a use case of connecting Oracle AQ JMS with Weblogic and using it in my SOA 11g process. I am trying to publish something to my queue that I created but I am getting this

  • Can't copy large files to AirPort Disk Using Windows 7

    Hi Everyone, I'm positng because I'm unable to copy large files to an AirPort Disk using Windows 7.  I have the following setup. AirPort Extreme: - Firmware version: 7.6.1 - Airport disks secured by password - No guest access allowed - Airport Disk P

  • Connecting Mac Book to the Home Theatre

    Does anyone have any idea as to how to connect the Macbook to the Home Theatre. I have movies on my Mac and want to watch them on my home theatre. The home theatre components are projector and a 5.1 Harman Kardon system.