Use Custom Fields to create Pedigree

Discussion in 'Technical Support' started by vlambert, Sep 15, 2008.

Thread Status:
Not open for further replies.
  1. vlambert Customer

    Is saw this post which I beleive is similiar to what I am trying to do. Custom layout for single category - posting and display
    But I did not understand the answer from Lhotch - "You can manually edit the viewlisting template to display the extra fields however you would like.

    Ive done exactly that for a pedigree in the past."

    Where do I edit the viewlisting template? I would like the customer to fill in the blanks for the custom fields when they add their listing and have those fields layed out like a family tree/pedigree. I would also like the title of the custom fields to not show in the viewlisting area, just the info. Of course I want the pedigree to look correct in the listing area also - I have the designer version of v4 and am using the horsegreen template. If anyone can assist that would be great - I see that there are posts about this - but so far I can't make the listing "look" like what I want it to look like. Not sure where to do this at....
  2. Eric Barnes Guest

    Hi,

    Is it possible to show an example of how you want it to look?
  3. Lhotch curmudgeon

    vlambert, go ahead and create a html table that has the exact pedigree layout your are looking for. in the table cells put in the name of the extra field that you created in the 68C admin. Then post the table code here and I will show you what you need to moify in the viewlisting template.

    NOTE, all I am interested in is the table structure that you want so go ahead and use your favorite html editor to create the table.
  4. vlambert Customer

  5. vlambert Customer

    Create table

    I will create the table now!
  6. vlambert Customer

    Table code

    .style28 {font-size: xx-small; font-weight: bold; }
    -->
    </style>
    </head>

    <body>
    <table width="594" height="80" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="140" rowspan="8" valign="middle"><div align="right" class="style28">
    <p>Name of Animal</p>
    </div></td>
    <td width="142" rowspan="4" valign="middle"><div align="left" class="style28">
    <p>Sire Name</p>
    </div></td>
    <td width="153" rowspan="2" valign="middle"><div align="left" class="style28">
    <p>Sires Sire Name</p>
    </div></td>
    <td width="159" height="20" valign="middle"><div align="left" class="style28">
    <p>Sires Sires Sire Name<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20"><div align="left" class="style28">
    <p>Sires Sires Dam Name<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td rowspan="2"><div align="left" class="style28">
    <p>Sires Dam Name </p>
    </div></td>
    <td height="20"><div align="left" class="style28">
    <p>Sires Dams Sire Name<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20"><div align="left" class="style28">
    <p>Sires Dams Dam Name <br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td rowspan="4" valign="middle"><div align="left" class="style28">
    <p>Dam Name</p>
    </div></td>
    <td rowspan="2" valign="middle"><div align="left" class="style28">
    <p>Dams Sire Name</p>
    </div></td>
    <td height="20" valign="middle"><div align="left" class="style28">
    <p>Dams Sires Sire Name<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20" valign="middle"><div align="left" class="style28">
    <p>Dams Sires Dam Name<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td rowspan="2"><div align="left" class="style28">
    <p>Dams Dam Name</p>
    </div></td>
    <td height="20"><div align="left" class="style28">
    <p>Dams Dams Sire Name<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20"><div align="left" class="style28">
    <p>Dams Dams Dam Name<br />
    </p>
    </div></td>
    </tr>
    </table>
    </body>
    </html>
  7. Lhotch curmudgeon

    Assuming you have other extra fields, besides those for the pedigree that you want displayed normally, here is what I would do.

    open viewlisting.tpl template and find this code...

    Code:
    {* Extra Fields *}
    			{foreach from=$extrafields item=extras}
    			<tr>
    				<td><strong>{$extras.title}:</strong></td>
    				<td>
    					{if isset($extras.value)}
    					  {foreach key=key item=item from=$extras.value}
    						{$item}<br />
    						{foreachelse}
    						{$extras.value}
    					  {/foreach}
    					 {/if}
    				</td>
    			</tr>
    			{/foreach}
    			{* End Extra Fields *}
    

    and replace it with this code.....

    Code:
    {* Extra Fields *}
      {foreach from=$extrafields item=extras}
    {if $extras.title=="Sires Sires Sire Name" || 
    	$extras.title=="Sires Sires Dam Name" || 
    	$extras.title=="Sires Dams Sire Name" ||
    	$extras.title=="Sires Dams Dam Name" ||
    	$extras.title=="Dams Sires Sire Name" ||
    	$extras.title=="Dams Sires Dam Name" ||
    	$extras.title=="Dams Dams Sire Name" ||
    	$extras.title=="Dams Dams Dam Name" ||
    	$extras.title=="Sires Sire Name" ||
    	$extras.title=="Sires Dam Name" ||
    	$extras.title=="Dams Sire Name" ||
    	$extras.title=="Dams Dam Name" ||
    	$extras.title=="Sire Name" ||
    	$extras.title=="Dam Name" ||
    	$extras.title=="Name of Animal"}
    	{$extras.title|replace:' ':''}
    {assign var=$extras.title value=$extras.value}
    {else}
        <tr>
          <td><strong>{$extras.title}:</strong></td>
          <td>
            {if isset($extras.value)}
              {foreach key=key item=item from=$extras.value}
                {$item}<br />
              {foreachelse}
                {$extras.value}
              {/foreach}
            {/if}
          </td>
        </tr>
    {/if}
      {/foreach}
    {* End Extra Fields *}
    
    I added evaluations in the loop to check the name field and if it equals one of your field names it will not display it normally but will assign it to a new variable whichis used in your html table code below.

    Just take the below html and plug it into your template where you want the pedigree table to appear.

    HTML:
    <table width="594" height="80" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="140" rowspan="8" valign="middle"><div align="right" class="style28">
    <p>{$NameofAnimal}</p>
    </div></td>
    <td width="142" rowspan="4" valign="middle"><div align="left" class="style28">
    <p>{$SireName}</p>
    </div></td>
    <td width="153" rowspan="2" valign="middle"><div align="left" class="style28">
    <p>{$SiresSireName</p>
    </div></td>
    <td width="159" height="20" valign="middle"><div align="left" class="style28">
    <p>{$SiresSiresSireName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20"><div align="left" class="style28">
    <p>{$SiresSiresDamName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td rowspan="2"><div align="left" class="style28">
    <p>{$SiresDamName}</p>
    </div></td>
    <td height="20"><div align="left" class="style28">
    <p>{$SiresDamsSireName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20"><div align="left" class="style28">
    <p>{$SiresDamsDamName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td rowspan="4" valign="middle"><div align="left" class="style28">
    <p>{$DamName}</p>
    </div></td>
    <td rowspan="2" valign="middle"><div align="left" class="style28">
    <p>{$DamsSireName}</p>
    </div></td>
    <td height="20" valign="middle"><div align="left" class="style28">
    <p>{$DamsSiresSireName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20" valign="middle"><div align="left" class="style28">
    <p>{$DamsSiresDamName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td rowspan="2"><div align="left" class="style28">
    <p>{$DamsDamName}</p>
    </div></td>
    <td height="20"><div align="left" class="style28">
    <p>{$DamsDamsSireName}<br />
    </p>
    </div></td>
    </tr>
    <tr>
    <td height="20"><div align="left" class="style28">
    <p>{$DamsDamsDamName}<br />
    </p>
    </div></td>
    </tr>
    </table>
    
  8. vlambert Customer

    problem

    I do not have any viewlisting.tpl template that I can find....
  9. Lhotch curmudgeon

    It would help if you told us what version of 68C you are using and what template you are using.

    there is a template file called viewlisting.tpl in


    /templates/default/viewlisting.tpl

    which is what I assumed you were using since you didnt give us any additional info.
  10. vlambert Customer

    sorry bout that

    this was in the original post - sorta near the end....I have the designer version of v4 and am using the horsegreen template.
  11. Lhotch curmudgeon

    ok, sorry I missed that.

    I dont have the horse green template so can only guess. If your certain there is no viewlisting.tpl in /templates/horsegreen then What I would do is copy the file /templates/default/viewlisting.tpl to the folder that has your horsegreen template in it and then modify that file.
  12. vlambert Customer

    would it make it easier

    if I showed you the horse green template? I could put up on an ftp site that I sue for clients to upload/download info?
  13. vlambert Customer

  14. Lhotch curmudgeon

    did you create the extra fields? And in turn fill them in for the ad in question?
  15. vlambert Customer

    extra fields

    yes - but must be doing something wrong - I would guess I inout the info you gave me OK as it is showing up. Just the wrong data and the wrong (filed names instead of the info) and the layout is not the table. Maybe I put the html that you gave me in the wrong place - where should that go? What "page"?

    Just take the below html and plug it into your template where you want the pedigree table to appear.
  16. Lhotch curmudgeon

    It need to go in the viewlisting.tpl temp;late, where you put the html code for the table depends on where you want the pedigree to appear.

    Also, in the logic where I evaluate the name of the field I am using the names of the fields you gave me so maybe something is wrong there.

    Do this. remove the code chunk I gave you in between the comment lines...

    {* Extra Fields *}

    and put it back the way it was so I cna look at the names of the extra fields etc.
  17. vlambert Customer

    this is done - and I really appreciate your help!
  18. Lhotch curmudgeon

    Ok, i redid things abit, now go back in and change the {* extra fields *} section with this code and post up when done.

    Code:
    {* Extra Fields *}
      {foreach from=$extrafields item=extras}
    {if $extras.fID=="1"}
    {assign var=NameofAnimal value=`$extras.value`}
    {elseif $extras.fID=="2"}
    {assign var=SiresSiresSireName value=`$extras.value`}
    {elseif $extras.fID=="4"}
    {assign var=SiresSiresDamName value=`$extras.value`}
    {elseif $extras.fID=="5"}
    {assign var=SireName value=`$extras.value`}
    {elseif	$extras.fID=="6"}
    {assign var=SiresDamsSireName value=`$extras.value`}
    {elseif $extras.fID=="7"}
    {assign var=SiresDamName value=`$extras.value`}
    {elseif $extras.fID=="8"}
    {assign var=SiresDamsDamName value=`$extras.value`}
    {elseif $extras.fID=="9"}
    {assign var=DamsSiresSireName value=`$extras.value`}
    {elseif $extras.fID=="10"}
    {assign var=DamsSireName value=`$extras.value`}
    {elseif $extras.fID=="11"}
    {assign var=DamsSiresDamName value=`$extras.value`}
    {elseif $extras.fID=="12"}
    {assign var=DamName value=`$extras.value`}
    {elseif $extras.fID=="13"}
    {assign var=DamsDamsSireName value=`$extras.value`}
    {elseif $extras.fID=="14"}
    {assign var=DamsDamName value=`$extras.value`}
    {elseif $extras.fID=="15"}
    {assign var=DamsDamsDamName value=`$extras.value`}
    {else}
        <tr>
          <td><strong>{$extras.title}:</strong></td>
          <td>
            {if isset($extras.value)}
              {foreach key=key item=item from=$extras.value}
                {$item}<br />
              {foreachelse}
                {$extras.value}
              {/foreach}
            {/if}
          </td>
        </tr>
    {/if}
      {/foreach}
    {* End Extra Fields *}
  19. vlambert Customer

    oops

    now nothing shows up - I must be doing something wrong - when I added the html code you gave me to the viewlisting.tpl it made it where NOTHING showed up at all - so I took it out and now just none of the info that I want shows up ....I am sorry for being such a headache and really appreciate your efforts...
  20. Lhotch curmudgeon

    It may have been my fault. I edited the code above, try it again. Just to reiterate where we are.

    The table htm you created and I tweaked should be removed altogether right now.

    The code I created above needs to take the place of the code in between the smarty comment lines.

    {* Extra Fields *}
    {* End Extra Fields *}

    P.S. I wrote this reply before I edited the above code so make sure the code you are using has the variable names that are not in double quotes and the value name is surrounded by back tics.
Thread Status:
Not open for further replies.

Share This Page