Skip to main content
Inspiring
Mar 16, 2022 9:22 AM UTC
Answered

Use attribute value for setting paragraph formating parameter

Hello,

This seems like a basic question but I couldn't find the answer yet:

I would like to use the integer value of a parameter to set the value of a paragraph formating parameter (here: number of allowed orphan lines)

Here is what my element looks like in the EDD:

Element (Container): Para
	General rule:	<TEXT> | etc...
	Attribute list
		Name: orphan_lines 	Integer 	Optional 
		Range: from 1    to 999
		Default:	1
	Text format rules
		In all contexts.
			Pagination properties
				Widow/orphan lines: orphan_lines

Nevertheless this doesn't work: the parameter "Window Orphan Lines" from Parafraph Designer doesn't get set to the value value of "orphan_lines"

Is the syntax I'm using correct ?

Thanx in advance

Best regards

Eric

    This topic is closed to new replies. Start a new post to keep the conversation going.
    frameexpert
    frameexpertCorrect answer
    Community Expert
    Mar 16, 2022 11:38 AM UTC

    An alternative to Russ's EDD approach would be to use ExtendScript. Here is a snippet that illustrates the basic concept:

     

     

    var doc, element, attrValue, pgf;
    
    // Assuming you have doc, element, and pgf objects in scope...
    // ...
    attrValue = getAttributeValue (element, "orphan_lines");
    if ((attrValue) && (attrValue !== "")) {
       pgf.BlockLines = attrValue;
    }
    
    function getAttributeValue (element, name) {
        
        var attrList = element.Attributes, i = 0;
        
        for (i = 0; i < attrList.length; i += 1) {
            if (attrList[i].name === name) {
                if (attrList[i].values[0] !== undefined) {
                    return (attrList[i].values[0]);
                }
            }
        }
    }
    

     

    www.frameexpert.com

    3 replies

    frameexpert
    Community Expert
    frameexpertCommunity ExpertCorrect answer
    Community Expert
    Mar 16, 2022 11:38 AM UTC

    An alternative to Russ's EDD approach would be to use ExtendScript. Here is a snippet that illustrates the basic concept:

     

     

    var doc, element, attrValue, pgf;
    
    // Assuming you have doc, element, and pgf objects in scope...
    // ...
    attrValue = getAttributeValue (element, "orphan_lines");
    if ((attrValue) && (attrValue !== "")) {
       pgf.BlockLines = attrValue;
    }
    
    function getAttributeValue (element, name) {
        
        var attrList = element.Attributes, i = 0;
        
        for (i = 0; i < attrList.length; i += 1) {
            if (attrList[i].name === name) {
                if (attrList[i].values[0] !== undefined) {
                    return (attrList[i].values[0]);
                }
            }
        }
    }
    

     

    Translate
    www.frameexpert.com
    Legend
    Mar 16, 2022 9:36 AM UTC

    Hi Eric,

    You can't reference an attribute value that way. It seems logical, but it's unfortunately not that flexible. You would need to reference the value in context rules in a more explicit manner, such as:

     

     

    ...unless somebody knows some syntax that I am forgetting. It's been a while since I wrote EDDs. Hope this helps.

     

    Russ

     

    [edit] Postscript... with this method, you probably would want to make the attribute a Choice type, so you can limit the values to only those supported by the context rules you specify.

     

     

    Translate
    Eric5F88Author
    Inspiring
    Mar 16, 2022 12:24 PM UTC

    Thanx a lot for your answer !

    Translate