Skip to main content
Inspiring
March 16, 2022
Answered

Use attribute value for setting paragraph formating parameter

  • March 16, 2022
  • 2 replies
  • 436 views

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 has been closed for replies.
    Correct answer frameexpert

    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]);
                }
            }
        }
    }
    

     

    2 replies

    frameexpert
    Community Expert
    frameexpertCommunity ExpertCorrect answer
    Community Expert
    March 16, 2022

    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]);
                }
            }
        }
    }
    

     

    Legend
    March 16, 2022

    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.

     

     

    Eric5F88Author
    Inspiring
    March 16, 2022

    Thanx a lot for your answer !