Bootstrap [responsive, mobile-ready]

Forum
Last Post
Threads / Messages
Both of these tasks can be done with a bit of Javascript. ^w^~

html - This goes just after the list of links ends, but before the end of the navbar.
Code:
   <span class="navbar-right timeboth"></span>

javascript/jquery - This can be included near the bottom, just before the end of the body INSIDE <script> </script> tags.
Code:
 var now = new Date();
var hrs = now.getHours();
var img = "";
var a_p = "";

if (hrs < 12) { a_p = "AM"; }
else { a_p = "PM"; }
if (hrs === 0) { hrs = 12; }
if (hrs > 12) { hrs = hrs - 12; }

var min = now.getMinutes();
if (min < 10) { var min = "0"+min; }
var time = hrs + ":" + min + " " + a_p +" ";

if (hrs >  0) img = "http://static.jsbin.com/images/jsbin_16.png"; // After midnight
if (hrs >  6) img = "http://static.jsbin.com/images/jsbin_16.png"; // After 6am
if (hrs > 12) img = "http://static.jsbin.com/images/jsbin_16.png"; // After noon
if (hrs > 17) img = "http://static.jsbin.com/images/jsbin_16.png"; // After 5pm
if (hrs > 22) img = "http://static.jsbin.com/images/jsbin_16.png"; // After 10pm

// If you want to use the time + a small image, use a class of "timeboth":
$(".timeboth").html(time+"<img src="+img+">").css({"color": "#fff", "padding": "15px 0 15px 0"});

// Any element with a class of "time" will be filled with the time:
$(".time").html(time);

// Any element with a class of "timeimg" will get its image:
$(".timeimg").html("<img src="+img+">");

I think you can get the jist of what's going on if you stare at it enough. ovo/ Right now it's got the same image displaying for everything, of course, but you can see where to change it from the examples above (as you can probably guess, the basis is military time, yet I've hacked the date to read as AM/PM).

A css fix has been added to the class of "timeboth" with a bit of jQuery to align it with the links of the Bootstrap header, but this fix has not been applied to "time" and "timeimg" in case you want to use those elsewhere. Feel free to copy that fix to the other two, imitate the format, or make css amends in an actual stylesheet. (I wasn't sure whether you wanted to use these separately or not. For all I know, you may want to change your entire header to a sunrise/sun/sunset/moon based on the time of day!)

Check out this jsbin I've made for a working example.

Keep in mind that this code is a mix of both Javascript and jQuery (for convenience). The Bootstrap theme comes bundled with jQuery already, anyone who doesn't have it will have to include a link to prior to inserting a script that requires it.

To anyone staring at this and going "wow that's neat" - yes, getMonth(); and getDate(); exist as well (and for full homework, see how the entire Date(); object in Javascript is constructed).

On a final note, the data received is only as current as the page load. So it will display information based on the time the page was loaded, and pulls it's time directly from the user's computer, and not the server. It will be up to the script creators to make something accurate to server time that a user cannot change simply by messing their computer clock. It's good for visual effects, but I wouldn't rely on it to do much more than that. And unlike server side code, anyone can view the source of the page and view its Javascript - so if you're hiding promo codes in images, someone could easily find them all.

It's also theoretically possible to pull data on the moon phase...... but I don't really feel like going into that. >_o
 
Last edited:
If you want the php version to keep doing it like what you have in Creche: http://stackoverflow.com/questions/6621572/how-to-get-date-and-time-from-server

After getting the server time, do a smarty assign like $mysidia->template->assign("time",$variableYouCreated), this makes it possible to use the variable {$time} in the template.tpl (just like {$sidebar} or {$menu}!) inside the tags Kyttias has mentioned.
Or like this http://www.smarty.net/docs/en/language.modifier.date.format.tpl#idp6286592
 
It's definitely smarter to do it with PHP if for any reason it has to do with promo codes, for obvious security reasons! The best designed sites flawlessly integrate beauty with purpose. It's nice to know Smarty has a built in function for server time! Definitely would have saved me half the effort last night.

- On what file does the smarty assign need to be made?
- To get an image to appear a specific time of day, but not display the time, I would still need at least this in Javascript:
Code:
var now = new Date();
var hrs = now.getHours();
var img = "";

if (hrs >  0) img = "http://static.jsbin.com/images/jsbin_16.png"; // After midnight
if (hrs >  6) img = "http://static.jsbin.com/images/jsbin_16.png"; // After 6am
if (hrs > 12) img = "http://static.jsbin.com/images/jsbin_16.png"; // After noon
if (hrs > 17) img = "http://static.jsbin.com/images/jsbin_16.png"; // After 5pm
if (hrs > 22) img = "http://static.jsbin.com/images/jsbin_16.png"; // After 10pm

// Any element with a class of "timeimg" will get its image:
$(".timeimg").html("<img src="+img+">");
- I'd love a quick lesson on how to format PHP for this instead. ovo~ It should be nearly the same? (There's a bit of shortcutting above as far as format goes, but I don't know how chill PHP is with forgoing conventional brackets.) So, safely, this would be the basic start, right? What would the next steps be, to make showing an image be as convenient showing the time like the Smarty assign?

Code:
$t = date("H");

if ($t>"0") { echo "<img src='http://static.jsbin.com/images/jsbin_16.png'>"; } // After midnight
if ($t>"6") { echo "<img src='http://static.jsbin.com/images/jsbin_16.png'>"; } // After 6am
if ($t>"12") { echo "<img src='http://static.jsbin.com/images/jsbin_16.png'>"; } // After noon
if ($t>"17") { echo "<img src='http://static.jsbin.com/images/jsbin_16.png'>"; } // After 5pm
if ($t>"22") { echo "<img src='http://static.jsbin.com/images/jsbin_16.png'>"; } // After 10pm

I'd like the end result to be as easy as going {$timeimg}? (I'm learning, I like this!) I think it needs to go in function (object?) that the smarty variable will be assigned to read the outcome of??
 
Last edited:
It works extremely perfect *_* Thank you so much, I even got it to display the server time by modifiying the script just a little.

This theme is awesome, btw, thanks for all the hard work :D
 
- It can be used on any file through $mysidia->template->assign(), as long as you declare mysidia ($mysidia = Registry::get("mysidia")). I've been using most assigns in class_template though, in assignTemplateVars() function, or in class_frame, but that's personal choice I guess. I chose those two since they are always loaded for every page

- You can also do an assign for the image link and then in the template use it wherever you want, like:

//in class_template
PHP:
//you can use any other date function you wish xD
$now = new DateTime();
$hrs = $now->format('G');
$img = "";

if ($hrs >  0) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After midnight
if ($hrs >  6) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After 6am
if ($hrs > 12) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After noon
if ($hrs > 17) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After 5pm
if ($hrs > 22) $img = "http://static.jsbin.com/images/jsbin_16.png"; // After 10pm

$this->assign("timeimg",$img);

//in template.tpl or header.tpl, wherever you want it
<img src={$timeimg}>

You can assign both the time and the image at once like this if you wish. Of course, it will only refresh with a page refresh xD

- PHP is pretty much normal with brackets, if the IF condition only has one line, you need no backets, like in Javascript ^^
 
Thankyou, that makes so much more sense. I hadn't had breakfast yet, my brain was in a fog. ^^

I added the code above into inside of the function assignTemplateVars(), which exists inside class_template.php, and it worked perfectly. My life suddenly got worlds easier.
 
Last edited:
Utterly brilliant. WOW. Thank you so much, I just installed this and it's incredible!!
 
Utterly brilliant. WOW. Thank you so much, I just installed this and it's incredible!!
 
:O

As many many people before me have said.. THIS THEME IS AMAZING! I love Bootstrap and having it made into a theme for Mysidia Adoptables is just awesome!
 
This is amazing! :BIGO:

I found a bug though, on mobile devices submenus aren't present.
 
No, they're not present. On the first post I explained you'll need to make pages for each top level category and link to them. You'll have to make these pages yourself, and they should contain the same content as the submenus. It's only as mobile friendly as you make it.
 
I couldn't get the style resource you posted to work properly, it didn't give the entire css.
I did however, find this website which I thought was useful.

http://www.lavishbootstrap.com/

My website is set on an island, so after searching around for the right image that gave a good palette, I ended up with a pretty nice style for the bootstrap theme.
 
Hey, Kyttias, I know you're busy, but when/if you have the chance I could use some suggestions!

For some reason every now and then my theme will sort of glitch and the button arrows for the drop down will, well, drop down below the link title. Not a major issue, but it doesn't look great- screenshot

Any ideas?
 
Definitely something that can be fixed with css, but I wonder why it only happens 'once in a while'? If I had a direct link I would just right click on the area when it's happening and hit 'inspect element' on the browser's context menu and examine what's going on there -- with the css. It looks as though the minimum width for those areas need to be wider.
 
I have a question about editing the bootstrap that you provided in the file! XD I made a fresh install of the bootstrap theme and haven't actually edited anything yet (well, I have, but I undid everything after because I didn't like it, etc. XD). I need help with making everything line up properly though... on the shop page that you helped me with originally Bootstrap kind of breaks it XD I'm not sure where to go to edit it so that everything fits better. I have spent the past few hours tinkering with the code in the Bootstrap file and the class_itemshop file but can't fix it. >.< Also, the tooltips don't work properly.

It looks like this:

  Spoiler: Image 
screenie_zpsujaextlp.png


I'm also wondering if there are any good Bootstrap tutorials that I can use to change the layout. I checked out the ones on the first post but I'm not sure how to use the info XD (That's also why I'm asking here about the layout and tooltips as I didn't understand what was on the links about them XD)
 
Bootstrap is a css theme but not really a layout. Yes, I made a layout, and you can change it. I'd advise you to use the information in the links, because the only thing I can do is tell you to do is read how to use Bootstrap from the original site. All the example code is there - html elements and the exact classes they need on them. Most of the other links I gave you are just ways to create themes - which are just arrangements of color and different sized borders, radius amounts, fonts choices, etc.

As for the tooltips not working, the thread you got them from informs you:
You now have all the necessary components for tooltips. You now also have jQuery, for future reference. If you already had jQuery, say, at the end of your </body> in your template.tpl (and if you have Bootstrap, you do), move the scripts there instead (but go ahead and leave the css in the header). These scripts must always come after your jQuery installation.

That is to say, if you have Bootstrap you must have jQuery in the header file and not the end of the template file. You also cannot have two. Neglecting to have it at the top or having more than one would cause issue. I don't know what your exact problem is. That said, Bootstrap also comes with built in tooltips, so if you'd rather rewrite the html completely, look into that.

On a final note, be careful when rewriting the shop files. I advise getting a text editor meant for code that has syntax highlighting, so you can visually see that the code is being closed correctly. Double quotes " , single quotes ' , and commented out quotes \" will all need to be used at different times and locations and they're the bane of even an advanced coder's day. Knowing what to use where and when is difficult, so I wish you luck.

I wish I had more time to offer help. Good luck! :happyc:
 
OK, thanks a lot! ^_^ I started college today and I went into the library and oh my lord the amount of coding books I found o.o There were so many........ o.o I got out one on CSS and HTML (even though I'm actually not bad at them because I had lessons at Secondary school before we chose what subjects to do) and I saw there were also AJAX ones, PHP ones, JQUERY ones, Javascript... and quite a few with multiple topics in them (like PHP, MySQL, and Ajax together). I'm definitely going to make use of those resources over the next, like, 2 years... although I have started reading the CSS one (it's CSS: The Definitive Guide 3rd Edition by Eric A. Meyer) and I actually already know all the info I've read so far XD I can't wait to start the HTML one after, as well. But I will also check out the PHP ones later on.. so I now have greater resources at my disposal!

It's going to be a huge help! XD And if I can't get Bootstrap to work to my liking, I have a solid idea for what I want to achieve with the normal CSS styling (that is for the first time an actual image in my head of what I wish it to look like). Now that I have a plan, I can hopefully do some of these things myself instead of always asking for help at all hours of the night when I am struck with an idea... >.> Which is what happened last night because my brain wouldn't shut off when I was supposed to be sleeping because all I could think about was coding sequences for CSS and a few basic PHP lines I remembered... not helpful when I had to have my first day at college today D: But anyway... thank you! XD

(If you can't tell I'm really excited right now lol OwO)
 
Please note:
You will NEED to go into Links > Edit Links and make sure your top-level categories are pointing to pages other than index, as the drop down menus have been removed for devices smaller than tablets! Make pages for your top-level categories that include all relevant links, so users on smaller screens can navigate all parts of your site. You can safely remove the link to 'Home' as it is redundant and will inaccurately display a drop down caret even though it has no drop down children.

I have changed the 'link text' of the top level categories to different links of the site. Does the links are still supposed collapse? They didn't show up for mobile...
 
Last edited:
No, unfortunately, the idea is to create a 'homepage' for each top level category that will contain all the necessary links therein, and people on mobile will navigate the site that way. It's not the best in the world. Sorry!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,115
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top