Our Gift to You: 20% off your own designs in Strong & Flexible Plastic through Dec 23, with promo code MY2014 · details
Home » Community » Shapeways Shops » HTML in description
Search Search  
Show: Today's Messages    Show Polls    Message Navigator
HTML in description [message #29191] Thu, 16 June 2011 22:09 UTC Go to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
With the invention of the 3d printed bikini I noticed they had HTML in there shop description. Once I realized HTML could be entered in the description I sorted my shop up and look at it now.

http://shapeways.com/shops/propmodule

I also realized just how many D6 I have made. Need to get working on more other numbers


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #29194 is a reply to message #29191 ] Thu, 16 June 2011 22:50 UTC Go to previous messageGo to next message
avatar sFsGaming  is currently offline sFsGaming
Messages: 80
Registered: January 2010
Go to my shop
Member
That's a lot of dice! Very Happy

Thank you for your description of a Hyper Cube. That's the only time I've heard it explained that way, and I finally get it! Very Happy
Re: HTML in description [message #29196 is a reply to message #29194 ] Thu, 16 June 2011 23:11 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
your welcome glad I could help explain it. I have had a fascination with hypercubes for quiet a while. It was a long time from when I designed it to when it could get printed. Only FUD is detailed enough.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #29204 is a reply to message #29196 ] Fri, 17 June 2011 06:04 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
I like the way you have classified your dice.
I did something similar but only for the tags, not the shop categories... Perhaps I should at least add categories for the number of sides... Thumbs Up

Concerning the D6, on the one hand there are probably the most used dice in games, but on the other hand they are so commonly used that it is easy to get them from cheaper production processes... So, I don't know. I guess that only the sales can tell you if they are worth spending time to design them or not...


So many things to design, so little time...
Re: HTML in description [message #29707 is a reply to message #29204 ] Sat, 25 June 2011 22:26 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
You can check my own navigation bar.
http://www.shapeways.com/shops/themagicshop
Actually it is a menu.
The style has been copied from Shapeways' one but I have some issue with the margins.
Fell free to enhance it (just get the code with a View source and search for "Magic")


So many things to design, so little time...
Re: HTML in description [message #29713 is a reply to message #29707 ] Sun, 26 June 2011 02:08 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Nice don't know why I did not think of that my standard menu like this requires a bit of javascript but as you said can borrow there scripts. This will condense the description section a lot thanks. Now if only the contents could be updated dynamically like the side bar.

Shapeways can I interest you into adding some sudo html tags would be great if I could enter the following instead of typing the number in. If you restrict the tags to name only and force a strict naming convention like shown below it is pretty easy.

(<SECTION_COUNT_section name>)

to

(5)

I have not double checked but I am pretty sure the following code will find and replace the code format above. Input $line, output $line, requires function lookupSectionCount($shopSectionName)


    $line = preg_replace_callback(
        '|<SECTION_COUNT_(.*)>|',
        create_function(
            // single quotes are essential here,
            // or alternative escape all $ as \$
            '$matches',
            'return lookupSectionCount($matches[0]);'
        ),
        $line
    );

[Updated on: Sun, 26 June 2011 02:09 UTC]


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #29756 is a reply to message #29713 ] Mon, 27 June 2011 06:46 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
In attachement you will find the code I used.

Unfortunately, I could not reuse the style of the main menu (and even less the code) from Shapeways bacause it uses id not class.
Furthermore, the code has not the same behaviour in a simple html page and in the Shop page, so probably there are some things I missed.

But I think it would be interesting to have some unifyed style in our page for menus. Menus allow to have a herarchy in the categories (one category than can split in several categories) and is really compact.
So any help from Shapeways to "standardize" a menu would be appreciate.
Ideally, to add a menu, I'd like to call some functions like
FirstMenuTitle("Title1", link1);
 MenuItem("Item1", link2);
 MenuItem("Item2", link3);
 MenuItem("Item3", link4)
MenuTitle("Title2", link5)
 MenuItem("Item1", link6)
 MenuItem("Item2", link7)
EndMenu()

  • Attachment: intro.htm
    (Size: 6.24KB, Downloaded 89 time(s))


So many things to design, so little time...
Re: HTML in description [message #29776 is a reply to message #29756 ] Mon, 27 June 2011 13:27 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
I use: http://spicebrains.com/multi-level-drop-down-menu/

cheap and lets you make a multi level menu entirely with HTML. The javascript runs at runtime and replaces any list with class mlddm with a nice menu. Maybe shapeways could get it. I have a spare license if they don't want to spend the $25.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #29789 is a reply to message #29776 ] Mon, 27 June 2011 19:39 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
Yes, this is a very elegant solution, better than what I proposed.
But, to do something similar (or trying to do something similar), I guess i would need to call an init function at onload time, and I don't know if I am allowed to do so (as far as I know, when you define an onload fuction it overrides all the previous ones)...


So many things to design, so little time...
Re: HTML in description [message #29791 is a reply to message #29789 ] Mon, 27 June 2011 19:59 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
yes. shapeways would need to call the onload function themselves. after that the script will do nothing if the appropriate class is not present or do what it is suppose to if the class is present. The javascripts onload can be called at any time. I call it after every ajax call that modifies my menu content because the menu will not change to match the html when changed via ajax unless you do this


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #29925 is a reply to message #29791 ] Wed, 29 June 2011 21:36 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
Here is a new version, with simplified HTML coding for the menu (no more javascript there) and some javascript because although IE9 support hover in li tags (in style definitions), you need to define a DOCTYPE which does not seems to be the case on Shapeways pages.
The style need probably to be reworked a little bit and there are some strange bugs on Firefox and Chrome (bullets on the lists) and some small inconsistencies in the width of the menu.
But it works more or less well and is very easier to add to your own page.
Just include the styles, the scripts (including the onload) and change the first <ul> into <ul id="menu">
As always, you can check the result in my shop: http://www.shapeways.com/shops/themagicshop

  • Attachment: intro3.htm
    (Size: 6.20KB, Downloaded 78 time(s))

[Updated on: Wed, 29 June 2011 21:46 UTC]


So many things to design, so little time...
Re: HTML in description [message #29935 is a reply to message #29925 ] Thu, 30 June 2011 03:17 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
looks good. assuming my daughter is not born this weekend I will have to write one for my shop this weekend. Maybe I can automate it since it seems shapeways is not responding about adding my little code snipit.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30082 is a reply to message #29935 ] Fri, 01 July 2011 21:22 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
strange for some reason menu does not work properly for me:

http://www.shapeways.com/shops/propmodule

However I did write a program to generate the menu here it is. Feel free to modify for your own uses:

<?php
function getBracket($str) {
  $start=strpos($str,'[')+1;
  $end=strpos($str,']',$start);
  return substr($str,$start,$end-$start);
}
  
  //download shop page
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_USERAGENT, 's2s');
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  //curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_URL, 'http://www.shapeways.com/shops/propmodule');
  //curl_setopt($ch, CURLOPT_POST, 1);
  //curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  $web_data = trim(curl_exec($ch));
  curl_close($ch);

  $start=strpos($web_data,'<h2>shop sections</h2>');
  $start=strpos($web_data,'all models',$start);
  
  //shop sections to look for
  $shopsec=array(
	'Solid Dice'=>0,
	'Hollow Dice'=>0,
	'Frame'=>0,
	'Metal Dice'=>0,
	'Non Dice'=>0,
	'Customizable'=>0,
	'Dice Set[Prime]'=>0,
	'Dice Set[Grid]'=>0,
	'Dice Set[Crystal]'=>0,
	'Dice Set[Dual]'=>0,
	'Dice Set[Frameless]'=>0,
	'Dice Set[Points]'=>0,
	'Specialty[Lottery]'=>0,
	'Specialty[Shell]'=>0,
	'Specialty[Loaded]'=>0,
	'Specialty[Data]'=>0,
	'Specialty[Math]'=>0,
	'Specialty[Obfuscation]'=>0,
	'Specialty[Ring]'=>0,
	'Specialty[4D]'=>0,
	'Specialty[Time]'=>0,
  );
  for ($i=0;$i<1000;$i++) {
    $shopsec['Sides['.substr('000' . $i,-3).']']=0;
  }

  //get quantity of each shop section
  foreach ($shopsec as $sec=>&$count) {
    $a=strpos($web_data,$sec,$start);
    $a=strpos($web_data,'(',$a)+1;
    $b=strpos($web_data,')',$a);
    $count=substr($web_data,$a,$b-$a);
  }


  echo '<ul id="menu" >';

  //Sides
  echo   '<li><a href="/shops/propmodule?section=Sides">Sides</a>';
  echo     '<ul>';
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,5)=='Sides') && ($count>0)) {
      echo   '<li ><a href="/shops//propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>';
    }
  }
  echo     '</ul>';
  echo   '</li>';

  //Build Type
  echo   '<li><a href="/shops/propmodule?section=Build Type">Build Type</a>';
  echo     '<ul>';
/*
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,10)=='Build Type') && ($count>0)) {
      echo   '<li ><a href="/shops//propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>';
    }
  }
*/
      echo   '<li ><a href="/shops//propmodule?section=Solid Dice">Solid Dice&nbsp;(' . $shopsec['Solid Dice'] . ')</a></li>';
      echo   '<li ><a href="/shops//propmodule?section=Hollow Dice">Hollow Dice&nbsp;(' . $shopsec['Hollow Dice'] . ')</a></li>';
      echo   '<li ><a href="/shops//propmodule?section=Frame">Frame&nbsp;(' . $shopsec['Frame'] . ')</a></li>';
  echo     '</ul>';
  echo   '</li>';


  //Dice Sets
  echo   '<li><a href="/shops/propmodule?section=Specialty">Dice Set</a>';
  echo     '<ul>';
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,8)=='Dice Set') && ($count>0)) {
      echo   '<li ><a href="/shops//propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>';
    }
  }
  echo     '</ul>';
  echo   '</li>';


  //Specialty Dice
  echo   '<li><a href="/shops/propmodule?section=Specialty">Specialty</a>';
  echo     '<ul>';
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,9)=='Specialty') && ($count>0)) {
      echo   '<li ><a href="/shops//propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>';
    }
  }
  echo     '</ul>';
  echo   '</li>';


  //Meterial
  echo   '<li><a href="/shops/propmodule?section=Specialty">Material</a>';
  echo     '<ul>';
/*
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,8)=='Material') && ($count>0)) {
      echo   '<li ><a href="/shops//propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>';
    }
  }
*/
      echo   '<li ><a href="/shops//propmodule?section=Metal+Dice">Metal Dice&nbsp;(' . $shopsec['Metal Dice'] . ')</a></li>';
  echo     '</ul>';
  echo   '</li>';

  //Other
  echo   '<li><a href="/shops/propmodule?section=Non Dice">Non Dice&nbsp;(' . $shopsec['Non Dice'] . ')</a></li>';
  echo   '<li><a href="/shops/propmodule?section=Customizable">Customizable&nbsp;(' . $shopsec['Customizable'] . ')</a></li>';

  echo '</ul>';
?>

[Updated on: Fri, 01 July 2011 21:24 UTC]


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30092 is a reply to message #30082 ] Sat, 02 July 2011 05:41 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
Great! I will look into this, thanks.

On your page, the main issue is the width and the height of your menu.

The total width should not exceed 620 pixels.
Each menu title is 120 except the last one that is as large as the menu items that are 160
So in my case I have 5 main titles: 4x120 + 160 = 640 and I am more or less in.
Try to reduce the 120px (in "li a") to 80px (6x80 +160 = 640).

For the heigh, my text is higher than the highest of the menu item list, so the menu items do not overlap the images. Try to add text or <br> to prevent the menu to be hidden by the images.

News from your daughter?


So many things to design, so little time...
Re: HTML in description [message #30094 is a reply to message #30092 ] Sat, 02 July 2011 05:58 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
nope daughter still not here yet.

As for menu. there must be a way to force the menu to the top so longer menus can be done.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30096 is a reply to message #30094 ] Sat, 02 July 2011 07:25 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Figured out why the menu did not work for me. As soon as the curser goes out of the division it stops working even if the menu will show longer. Guess I will have to write something to fill up some space and try to figure out a way to make my sides menu 3 columns instead of 1.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30098 is a reply to message #30096 ] Sat, 02 July 2011 09:07 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Here is my new code that generates the entire thing. Has 2 constants at begining to setup the style info. Fixed it so menu will roll over images and long menus can still be selected. Did not figure out how to make long menus shorter and 2 or 3 wide though.

<?php
  define('ITEM_WIDTH',122);	//Max width needed for items to show properly
  define('CAT_COUNT',6);	//Number of main categories
?>
<!-- Magic begin-->

<style type="text/css">
#menu
{
	z-index: 1000;
}

#menu, #menu ul    
{
        font-family : Arial,Helvetica,sans-serif;
        font-size : 12px;
        position : absolute; 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        list-style-type : none; /* delete any list style */
        list-style-image : none;
        line-height : 20px; 
        text-align : left; 
}

#menu li      
{ 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        float : left; 
}

#menu li a /* link in menu title */
{
        font-weight : bold; 
        display : block; 
        padding : 10; 
        background : #015BBB;         
        text-decoration : none; 
        width : <? echo ceil((620-ITEM_WIDTH)/CAT_COUNT); ?>px; 
        color : #AACCCC; 
        border-left : 1px solid #015BBB; /*no border but need to avoid a shift when actual border appears */
}

#menu li a:hover  /* if mouse over menu title */
{
        color : #FFFFFF;
        border-left : 1px solid #FFFFFF;
}

#menu li ul /* block of menu items */
{ 
        display: none;
        list-style-type : none; /* delete any list style */
        list-style-image : none;
        background : #FFFFFF;         
        color : #6699CC; 
        width: <? echo ITEM_WIDTH; ?>px; 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        border-left : 1px solid #015BBB; 
        border-right : 1px solid #015BBB; 
        border-bottom : 1px solid #015BBB;
}

#menu li.over ul /* block of menu items */
{ 
        display: block;
        list-style-type : none; /* delete any list style */
        list-style-image : none
        background : #FFFFFF;         
        color : #6699CC; 
        width: <? echo ITEM_WIDTH; ?>px; 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        border-left : 1px solid #015BBB; 
        border-right : 1px solid #015BBB; 
        border-bottom : 1px solid #015BBB;
}

#menu li ul li 
{
        border-top : 1px solid #F0F1F5; /* separation between items*/
}

#menu li ul li a /* link in menu item */
{
        font-weight : normal; 
        display : block; 
        padding-left : 2; 
        padding-top : 2; 
        padding-bottom : 2; 
        padding-right : 2; 
        text-decoration : none; 
        text-align : left; 
        width : <? echo (ITEM_WIDTH-2); ?>px;/* 162-1 -1 (?) */
        color : #6699CC; 
        background : #FFFFFF;         
        border-left : 1px solid #FFFFFF; /*no border but need to avoid a shift when actual border appears */
}

#menu li ul li a:hover /* if mouse over menu item */
{
        background : #E1F2FA;        
        color : #6699CC; 
        border-left : 1px solid #E1F2FA; /*no border but need to avoid a shift when actual border appears */
}

#menu #lastmenu a  
{
        width : <? echo (ITEM_WIDTH-2); ?>px ;
}
</style>

<script type="text/javascript">
function InitMenu(id)
{
  var ParentNode = document.getElementById(id);
  var ChildNodesArray = ParentNode.childNodes;
  if (ChildNodesArray == null) return;
  
  for (var i = 0; i < ChildNodesArray.length; i++)
  {
    var ChildNode = ChildNodesArray[i];
    if (ChildNode.nodeName.toLowerCase() == "li")
    {
      ChildNode.onmouseover = function()
      {
        this.className+=" over"; 
      }                                 
      ChildNode.onmouseout = function()
      {
        this.className=this.className.replace(" over", "");
      }                 
    }
  }
  
  changeStyle();
}


onload=function()
{InitMenu('menu');}
</script>




<?php
function getBracket($str) {
  $start=strpos($str,'[')+1;
  $end=strpos($str,']',$start);
  return substr($str,$start,$end-$start);
}
  
  //download shop page
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_USERAGENT, 's2s');
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  //curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_URL, 'http://www.shapeways.com/shops/propmodule');
  //curl_setopt($ch, CURLOPT_POST, 1);
  //curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  $web_data = trim(curl_exec($ch));
  curl_close($ch);

  $start=strpos($web_data,'<h2>shop sections</h2>');
  $start=strpos($web_data,'all models',$start);
  
  //shop sections to look for
  $shopsec=array(
	'Solid Dice'=>0,
	'Hollow Dice'=>0,
	'Frame'=>0,
	'Metal Dice'=>0,
	'Non Dice'=>0,
	'Customizable'=>0,
	'Dice Set[Prime]'=>0,
	'Dice Set[Grid]'=>0,
	'Dice Set[Crystal]'=>0,
	'Dice Set[Dual]'=>0,
	'Dice Set[Frameless]'=>0,
	'Dice Set[Points]'=>0,
	'Specialty[Lottery]'=>0,
	'Specialty[Shell]'=>0,
	'Specialty[Loaded]'=>0,
	'Specialty[Data]'=>0,
	'Specialty[Math]'=>0,
	'Specialty[Obfuscation]'=>0,
	'Specialty[Ring]'=>0,
	'Specialty[4D]'=>0,
	'Specialty[Time]'=>0,
  );
  for ($i=0;$i<1000;$i++) {
    $shopsec['Sides['.substr('000' . $i,-3).']']=0;
  }

  //get quantity of each shop section
  foreach ($shopsec as $sec=>&$count) {
    $a=strpos($web_data,$sec,$start);
    $a=strpos($web_data,'(',$a)+1;
    $b=strpos($web_data,')',$a);
    $count=substr($web_data,$a,$b-$a);
  }


  echo '<ul id="menu" >';

  //Sides
  echo   '<li><a href="/shops/propmodule?section=Sides">Sides</a>'."\n";
  echo     '<ul>'."\n";
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,5)=='Sides') && ($count>0)) {
      echo   '<li ><a href="/shops/propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>'."\n";
    }
  }
  echo     '</ul>'."\n";
  echo   '</li>'."\n";

  //Build Type
  echo   '<li><a href="/shops/propmodule?section=Build Type">Build Type</a>'."\n";
  echo     '<ul>'."\n";
/*
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,10)=='Build Type') && ($count>0)) {
      echo   '<li ><a href="/shops//propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>'."\n";
    }
  }
*/
      echo   '<li ><a href="/shops/propmodule?section=Solid Dice">Solid Dice&nbsp;(' . $shopsec['Solid Dice'] . ')</a></li>'."\n";
      echo   '<li ><a href="/shops/propmodule?section=Hollow Dice">Hollow Dice&nbsp;(' . $shopsec['Hollow Dice'] . ')</a></li>'."\n";
      echo   '<li ><a href="/shops/propmodule?section=Frame">Frame&nbsp;(' . $shopsec['Frame'] . ')</a></li>'."\n";
  echo     '</ul>'."\n";
  echo   '</li>'."\n";


  //Dice Sets
  echo   '<li><a href="/shops/propmodule?section=Specialty">Dice Set</a>'."\n";
  echo     '<ul>'."\n";
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,8)=='Dice Set') && ($count>0)) {
      echo   '<li ><a href="/shops/propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>'."\n";
    }
  }
  echo     '</ul>'."\n";
  echo   '</li>'."\n";


  //Specialty Dice
  echo   '<li><a href="/shops/propmodule?section=Specialty">Specialty</a>'."\n";
  echo     '<ul>'."\n";
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,9)=='Specialty') && ($count>0)) {
      echo   '<li ><a href="/shops/propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>'."\n";
    }
  }
  echo     '</ul>'."\n";
  echo   '</li>'."\n";


  //Meterial
  echo   '<li><a href="/shops/propmodule?section=Specialty">Material</a>'."\n";
  echo     '<ul>'."\n";
/*
  foreach ($shopsec as $key=>$count) {
    if ((substr($key,0,8)=='Material') && ($count>0)) {
      echo   '<li ><a href="/shops/propmodule?section=' . $key . '">' . getBracket($key) . '&nbsp;(' . $count . ')</a></li>'."\n";
    }
  }
*/
      echo   '<li ><a href="/shops/propmodule?section=Metal+Dice">Metal Dice&nbsp;(' . $shopsec['Metal Dice'] . ')</a></li>'."\n";
  echo     '</ul>'."\n";
  echo   '</li>'."\n";

  //Other
  echo   '<li><a href="/shops/propmodule?section=Non Dice">Non Dice&nbsp;(' . $shopsec['Non Dice'] . ')</a></li>'."\n";
  echo   '<li id="lastmenu"><a href="/shops/propmodule?section=Customizable">Customizable&nbsp;(' . $shopsec['Customizable'] . ')</a></li>'."\n";

  echo '</ul>'."\n";
?>


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30099 is a reply to message #30098 ] Sat, 02 July 2011 09:52 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
Excellent. Well done!
I did not know we could use php. this open new possibilities...


So many things to design, so little time...
Re: HTML in description [message #30109 is a reply to message #30099 ] Sat, 02 July 2011 14:38 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
No you can't use php. I executed this on my own server and cut and paste the source code. Just this way it auto grabs the correct number of dice in each category.

[Updated on: Sat, 02 July 2011 14:56 UTC]


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30125 is a reply to message #30109 ] Sat, 02 July 2011 22:23 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
I am working on a generic script that will work for everyone. All you will have to execute is

startmenu(shopname,cat1,cat2,cat3...);

as long as your shop sections are in the format:

catname[subcatname]


if anyone can figure out how to make long menu items rap to 2,3,4 columns would be great then I could write that feature in also.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30163 is a reply to message #30125 ] Mon, 04 July 2011 07:41 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Unfortunetly turns out cross platform ajax calls are not allowed so my generic script is not allowed. But here is the next best thing. Everything that needs modifying is in the first few lines it will generate everything after that. This works only if you have the naming convention stated above.

<?php
  $shop='propmodule';
  $cats=array('Sides','Build Type','Dice Set','Specialty','Material','Non Dice','Customizable');
  define('ITEM_WIDTH',122);	//Max width needed for items to show properly
  define('CAT_COUNT',6);	//Number of main categories

  //dont touch after this point.
?>

<style type="text/css">
#menu
{
	z-index: 1000;
}

#menu, #menu ul    
{
        font-family : Arial,Helvetica,sans-serif;
        font-size : 12px;
        position : absolute; 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        list-style-type : none; /* delete any list style */
        list-style-image : none;
        line-height : 20px; 
        text-align : left; 
}

#menu li      
{ 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        float : left; 
}

#menu li a /* link in menu title */
{
        font-weight : bold; 
        display : block; 
        padding : 10; 
        background : #015BBB;         
        text-decoration : none; 
        width : <? echo ceil((620-ITEM_WIDTH)/CAT_COUNT); ?>px; 
        color : #AACCCC; 
        border-left : 1px solid #015BBB; /*no border but need to avoid a shift when actual border appears */
}

#menu li a:hover  /* if mouse over menu title */
{
        color : #FFFFFF;
        border-left : 1px solid #FFFFFF;
}

#menu li ul /* block of menu items */
{ 
        display: none;
        list-style-type : none; /* delete any list style */
        list-style-image : none;
        background : #FFFFFF;         
        color : #6699CC; 
        width: <? echo ITEM_WIDTH; ?>px; 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        border-left : 1px solid #015BBB; 
        border-right : 1px solid #015BBB; 
        border-bottom : 1px solid #015BBB;
}

#menu li.over ul /* block of menu items */
{ 
        display: block;
        list-style-type : none; /* delete any list style */
        list-style-image : none
        background : #FFFFFF;         
        color : #6699CC; 
        width: <? echo ITEM_WIDTH; ?>px; 
        padding : 0; /* no internal margin */
        margin : 0; /* no external margin */
        border-left : 1px solid #015BBB; 
        border-right : 1px solid #015BBB; 
        border-bottom : 1px solid #015BBB;
}

#menu li ul li 
{
        border-top : 1px solid #F0F1F5; /* separation between items*/
}

#menu li ul li a /* link in menu item */
{
        font-weight : normal; 
        display : block; 
        padding-left : 2; 
        padding-top : 2; 
        padding-bottom : 2; 
        padding-right : 2; 
        text-decoration : none; 
        text-align : left; 
        width : <? echo (ITEM_WIDTH-2); ?>px;/* 162-1 -1 (?) */
        color : #6699CC; 
        background : #FFFFFF;         
        border-left : 1px solid #FFFFFF; /*no border but need to avoid a shift when actual border appears */
}

#menu li ul li a:hover /* if mouse over menu item */
{
        background : #E1F2FA;        
        color : #6699CC; 
        border-left : 1px solid #E1F2FA; /*no border but need to avoid a shift when actual border appears */
}

#menu #lastmenu a  
{
        width : <? echo (ITEM_WIDTH-2); ?>px ;
}
</style>

<script type="text/javascript">
function InitMenu(id)
{
  var ParentNode = document.getElementById(id);
  var ChildNodesArray = ParentNode.childNodes;
  if (ChildNodesArray == null) return;
  
  for (var i = 0; i < ChildNodesArray.length; i++)
  {
    var ChildNode = ChildNodesArray[i];
    if (ChildNode.nodeName.toLowerCase() == "li")
    {
      ChildNode.onmouseover = function()
      {
        this.className+=" over"; 
      }                                 
      ChildNode.onmouseout = function()
      {
        this.className=this.className.replace(" over", "");
      }                 
    }
  }
  
  changeStyle();
}


onload=function()
{InitMenu('menu');}
</script>






<?php
function getBracket($str) {
  $start=strpos($str,'[')+1;
  $end=strpos($str,']',$start);
  return substr($str,$start,$end-$start);
}



  //download shop page
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_USERAGENT, 's2s');
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  //curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_URL, 'http://www.shapeways.com/shops/' . $shop);
  //curl_setopt($ch, CURLOPT_POST, 1);
  //curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  $web_data = trim(curl_exec($ch));
  curl_close($ch);

  //get shop sections
  $start=strpos($web_data,'<h2>shop sections</h2>');
  $start=strpos($web_data,'all models',$start);
  $start=strpos($web_data,'<br>',$start)+4;
  $end=strpos($web_data,'</div>',$start);
  $web_data=trim(substr($web_data,$start,$end-$start));

  //process shop section into array with quantities
  $lines=explode("\n",$web_data);
  $sections=array();
  foreach ($lines as $line) {
    $a=strpos($line,'>')+1;
    $b=strpos($line,'<',$a);
    $c=strpos($line,';(',$b)+2;
    $d=strpos($line,')',$c);
    $sections[substr($line,$a,$b-$a)]=substr($line,$c,$d-$c);
  }

  //print menu
  echo '<ul id="menu" >';
  foreach ($cats as $cat) {

    //print section title
    if (isset($sections[$cat])) {
      echo '<li><a href="/shops/propmodule?section=' . urlencode($cat) . '">' . $cat . '&nbsp;(' . $sections[$cat] . ')</a>'."\n";
    } else {
      echo '<li><a href="/shops/propmodule?section=' . urlencode($cat) . '">' . $cat . '</a>'."\n";

      //print subsections
      $length=strlen($cat);
      $subs=array();
      foreach ($sections as $section=>$count) {
        if (substr($section,0,$length)==$cat) {
          $subs[]='<li ><a href="/shops/propmodule?section=' . urlencode($section) . '">' . getBracket($section) . '&nbsp;(' . $count . ')</a></li>';
        }
      }

//      if (count($subs)>0) {
        echo   '<ul>'."\n";
        foreach ($subs as $sub) {
          echo $sub . "\n";
        }
        echo     '</ul>'."\n";
//      }
    }

    //end section
    echo   '</li>'."\n";
  }
  echo '</ul>'."\n";
?>


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30174 is a reply to message #30163 ] Mon, 04 July 2011 15:03 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Ok for those of you that do not have a php server here is a live script for you to use:

Magic Menu Generator

If anyone has any improvements to add. Especially how we can make multi column sub categories please let me know and I will write them in.

Also let me know if the instructions need improving

[Updated on: Mon, 04 July 2011 15:10 UTC]


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30245 is a reply to message #30174 ] Tue, 05 July 2011 20:58 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
A new version where you can add a text that is specific to a category (just use the appropriate div (class must be "cat" and id must be the end of the URL of the category, just after the part "?section=").
Note that in the current implementation, if the string of an id contains another id (example "Dice" is contained into "Truncated+Sphere+Dice") then both div will be displayed.
You can test on my shop on the Dice category and all its sub-categories and also in the Glazed Ceramics sub-category (other text will come later)

Mctrivia, I don't know if this can also be make automatically (I guess it can be diffuclt to enter all the text in a form) but if it can be done, feel free to try to do so....
Thanks!

As usual, the code is in attachment.

  • Attachment: intro3.htm
    (Size: 7.79KB, Downloaded 90 time(s))


So many things to design, so little time...
Re: HTML in description [message #30271 is a reply to message #30245 ] Wed, 06 July 2011 05:59 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Ya I can add this to the auto generator. I will also add it so you can chose naming conventions

cat[subcat]
cat - subcat

that way you can use it also without renaming all categories.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30272 is a reply to message #30271 ] Wed, 06 July 2011 06:05 UTC Go to previous messageGo to next message
avatar Magic is currently online Magic
Messages: 1196
Registered: August 2008
Go to my shop
Shapie Expert
Shapeways Crew
This would be fantastic. Thanks!


So many things to design, so little time...
Re: HTML in description [message #30274 is a reply to message #30272 ] Wed, 06 July 2011 07:26 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
Well I have to go to bed. Have not added the changes yet for different naming conventions.

Made a huge improvement though. Before to update the quantities you had to re run script then cut and paste new code. Now you don't have to. Will do naming conventions first thing tomorrow then see about adding the description per category. I will just auto generate divs for each category so you can fill your html in or leave blank.


Check out my shop for example of the new menu.

[Updated on: Wed, 06 July 2011 07:26 UTC]


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30285 is a reply to message #30274 ] Wed, 06 July 2011 14:48 UTC Go to previous messageGo to next message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
ok magic will work for you now. except you need to remove the main categories as it stops processing if it finds one. You can still get the main categories without actually creating them.

Also added your improvements. Auto creates a div for each category. Sub categories you need to add yourself.

[Updated on: Wed, 06 July 2011 15:07 UTC]


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/
Re: HTML in description [message #30293 is a reply to message #30285 ] Wed, 06 July 2011 17:50 UTC Go to previous message
avatar mctrivia  is currently offline mctrivia
Messages: 808
Registered: September 2010
Go to my shop
Senior Member
made 2 quick improvements:

1) Menu is now cashed for 1 hour to save bandwidth and speed up load time
2) forced shapeways menu to top so shop menu does not get in front of site menu.


Follow me on twitter http://twitter.com/mctrivia or my blog at http://4ddice.blogspot.com/

 
   
Previous Topic:Shop Categories improvement
Next Topic:FD / FUD startup costs

Logo

Hello.

We're sorry to inform you that we no longer support this browser and can't confirm that everything will work as expected. For the best Shapeways experience, please use one of the following browsers:

Click anywhere outside this window to continue.