NoDice
Members-
Posts
80 -
Joined
-
Last visited
Everything posted by NoDice
-
Attaching iteration number to foreach-generated HTML-tags.
NoDice replied to NoDice's topic in Getting Started
Thanks guys for the lightning replies - that is what I am looking for (at least for the first part)! The second part of my problem is that I somehow need to get the number produced for color reference on another page. From the beginning I set ordering numbers manually in admin, but that didn't feel like a very good solution (and I ran into some other problems since I have a checkbox that you tick if you want the item to be included in a menu and so on). So any ideas would great to hear! I guess one way would be to run the full iteration and then hide all instances that does not match the page title. Does not feel very good though. -
Attaching iteration number to foreach-generated HTML-tags.
NoDice replied to NoDice's topic in Getting Started
A follow-up question is how I would be able to retrieve those ordering numbers from another page where I also want to make a color selection based on the order number produced by the itterations on the first page (menu items that need to be the same color as the dynamically created menu-items across pages)? In my case, a business area is assigned a color in an accordion and an index page based on the ordering number I want to create; and then that color has to also be used on the in-dept page for that business area (so I will need to grab the ordering number again). -
Tried to search but could not find a description of a good way to produce an ordering number (to use as classes in HTML-tags) based on the iteration order using foreach. Would be very helpful for any tips or hints on where I can find a method. By ordering numbers I mean from 1 to whatever based on the iterations resulting from the foreach loop where the tag in question is generated. Cheers from a sunny Stockholm!
-
Thanks so much for that suggestion and taking the time to write it down, I will give it a try! (I did not think of the fact that the percentages could be altered by using inline style.) **Worked great in my design! Still don't quite like he inline style, but I can certainly live with it. Thanks again!**
-
1 Since more logos will be added with time and I just want the users to add images in the CMS and have them spread out evenly over the row. 2 Since the numbers will range up and down from 3 to perhaps 6-7 images. The goal is not to have to touch the style or markup when you add images. 3 No max per se, but of course there will be a limit based on space and it will be pretty obvious when that gets crossed, and I don't see that being reached anyway. 4 No, that is the point, sorry for not making that clearer. The number of logos in the row will change. The goal would be to have it work 100% dynamically from the CMS, but if I give that up, I know I have lots of options. php in stylesheets could also handle the problem I guess, but I was advised against going that rout.
-
I have to ask one more thing in relation to this. I have made a repeater with images that are supposed to line up in an evenly spaced row using the last technique described here (inline block and justified): http://css-tricks.com/equidistant-objects-with-css/ I have only gotten this to work using background-style which I can only set from CSS. The point is to just being able to keep adding images (in this case logos) and having them line up evenly spaced without using percentages that change etc - and the repeater seems ideal for that. But then I can't use the repeater to set background images as I believe I need urls for the CSS inline style, and the asset folders get dynamically produced. What an I missing as far as how to solve this? Or is there no way to make it work as I planned? *** EDIT: Maybe I could instead generate div-classes depending on how many logos I put in, and then have different styles in the css for up to as many classes as I see as the maximum that would feasibly be used. Seems a bit messier but if that is the only way, suggestions on how to generate class-names depending on number of repeater-items would be much appreciated. ***
-
Yea now it works (after correcting my code error)! I had to go with if (wire("user")->language->name and "english" though to get it to act differently between the languages (since i use "english" for my secondary language). Thanks a lot again Soma!
-
Ah, that is surely the problem! Thanks, I thought direct calls to the API was the same. Will let you know after I test!
-
Yea, that was the first thing I tried, but I get: Notice: Undefined variable: user
-
I have an additional question about this. There are some things I have to change manually. For instance i have a custom made Swedish php-function to produce the desired date format. On my English page, I need that function to be replaced with a standard English format. How do I make a simple check if the current language is English for instance (to be used in an if statement to decide which date function to use)? I should perhaps add that it is for use within a function.
-
Yea, absolute worked (I only tried all kinds of internal ones). Makes for a little bit less portability, but if that is the way i have to go, it's certainly OK - thanks guys!
-
Just implemented this on the site I am doing and I have to say that this is just pure awesomeness! Exactly the way I want things to work when it comes to languages. Thanks, Ryan, for understanding and paying attention to the importance of multi-language support for us poor souls that are not from English speaking nations. I do have one problem though that I wanted to ask the forum about. I have this loaded in my main.js to get the pin I want on my google map: var infoWindow = new google.maps.InfoWindow(); var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); var image = { url: '../site/assets/files/1206/pin.png', size: new google.maps.Size(64, 75), origin: new google.maps.Point(0,0), anchor: new google.maps.Point(28, 76) }; var shadow = { url: '../site/assets/files/1206/shadow.png', size: new google.maps.Size(105, 52), origin: new google.maps.Point(0,0), anchor: new google.maps.Point(0, 56) }; Works great on my default page, but it won't load the pin (the map loads great apart from that) on the second language page. I recon it has to do with the links. Tried some variations but could not get it going (and I have to find some way to make it work on both pages). Any suggestions?
-
Yey! That did the trick, I did not even know there was a cache. Sorry about that. And also thanks a lot for the work on markupsimplenavigation and modules manager - they have been a great help!!
-
OK friends, I tried to install and uninstall the markupsimplenavigation (I am using modules manager). I tried to remove all but the non-standard options (certainly a good idea although it seems to protest before the options). I tried to zip all the files and then extract on server. All of this produced the exact same error and error message as before. Could it be a server side problem? If so, what?
-
Well, I don't think it is a file transfer problem as I take the entire site including all hidden files (and the hidden files are on the server). Once again, it also got going, and it runs without the navigation section. Will try your suggestion if all else fails though and let you know if it does the trick!
-
Thanks, will try the uninstall - install. I upload the whole site using ftp (and remove everything before I do) AND I drop and reimport current mysql-database. After that I change the rewrite base and the site config.php-settings to reflect the hosted settings. That's it. Note that if I remove the html above - everything rocks and rolls (but the navigation menu), and also that I once got it up and running by just adding and removing a line. Will let you know how I fare after the reinstall.
-
I'm still not having any luck with this. I would be really grateful for any hints on weather it might be some setting on the service provider's end or if I could have done something strange or dumb on my end (that I just can't see at the moment since it is working great in dev and since I actually got it started on the remote once by just adding and then removing some code).
-
I now tried removing these lines from my header while on the externally hosted server: <div id="navbar_full"> <div id="navbar_field"> <div id="logo"><a href="./"><img src="<?php echo $pages->get("/site-settings/")->top_menu_logo_01->url; ?>"></a> </div> <div id="lang"> <ul> <li class="current"><a href="./">Sv</a></li> <li><a href="./">Eng</a></li> </ul> </div> <nav> <?php include("./topnav_01.inc"); ?> </nav> <div class="clear"></div> </div> </div> And then everything works fine (sans top navigation of course). So clearly something is going on with my code in relation to the server environment. Strangest thing is that it started working yesterday and then did so without glitch. I should perhaps also mention that it renders the logo and the lang-parts so it seems to be in the markupsimplenavigation call things fall apart. I think it is all standard there though and, once again, never had this problem (or anything like it) in my own dev environments.
-
Yesterday I moved my work in progress site to the hosted server for the first time (I had only had the standard pw-installation there before). I immediately ran into problems and I got this error message: The lines in question are where markup simple navigation is called: <?php $treeMenu = $modules->get("MarkupSimpleNavigation"); // load the module echo $treeMenu->render($options = array( 'parent_class' => 'parent', 'current_class' => 'current', 'has_children_class' => 'has_children', 'levels' => true, 'levels_prefix' => 'level', 'max_levels' => null, 'firstlast' => true, 'collapsed' => false, 'show_root' => true, 'selector' => '', 'outer_tpl' => '<ul>||</ul>', 'inner_tpl' => '<ul>||</ul>', 'list_tpl' => '<li%s>||</li>', 'list_field_class' => '', 'item_tpl' => '<a href="{url}">{title}</a>', 'item_current_tpl' => '<a href="{url}">{title}</a>', 'xtemplates' => '', 'xitem_tpl' => '<span>{title}</span>', 'xitem_current_tpl' => '<span>{title}</span>' )); ?> The strange thing is that after putting some test line in, I think it was echo $treeMenu; between line 3 and 4, it started working! After removing the line, it kept working just fine and without any glitch all day (all pages and functions on the site). Not sure if it was the change or if it just started working after something had been cached or so on the server in the external host environment. Anyway, I uploaded again late last night, and I got the same error message, and this time, I can't get it going. Very strange. Anyone seen anything like it, or have any suggestions as to what might be going wrong?
-
Soma, beautiful, and I now integrated the latter version giving the exact same effect on my page as the messier code I had come up with. And yea, I am sure the mistake is common to other languages, but php is the first coding I am dealing with (except a brief stint with static HTML and CSS when I helped a friend build a simple site some 10 years ago). Things are progressing at a better pace now though, so I may share the project if I get it finished in a month or so (my real job to attend to as well I am afraid). Really appreciate the quick help from the forum as usual!
-
OK, I just thought this was not really pw related in a way that could help others but more just a basic php-question. I will still start new ones from now on if that is preferred. Thanks for the response on that.
-
Thanks ever so much, works great now! And truly embarrassing of course, as even I have read about people making that mistake many times before in the few weeks I have tried to learn a little about php...
-
OK, I have another noob-question (and I will stick to my thread here as I don't want to spam the forum with new topics, if new topics are preferred, please let me know). I figured I'd ask you php-wizards what I am doing wrong here as I'm trying to figure out why this does not work: function categoriesList(){ echo "<div class='categories'>"; echo "<div class='list_heading'><p>" . wire("pages")->get('/news/')->categories_heading_01 . "</p></div>"; $categories = wire("pages")->find("parent=/news-categories/, template=news_index_01, sort=title"); $out =" "; $thisCategory = wire("page")->title; foreach($categories as $category){ $category_active = $category->title; if ($category_active = $thisCategory) { $out .="<li class='active_category'><a href='{$category->url}'>{$category->title}</a></li>"; } else { $out .="<li><a href='{$category->url}'>{$category->title}</a></li>"; } } echo "<ul>$out</ul>"; echo "</div>"; } It is the "if"-statement that is the problem as it returns true for all instances. What I want to do is assign a class to the active category (which is the one that is the same as the page). I figure somehow it looks at all the instances when answering, but since "$category->title" correctly outputs all the different categories in the foreach-part, I am little confused by that.
-
That is probably the case as I am developing for my own businesses and just want a nice overview of what custom assets are linked to that page. I would be kind of surprised if there are not more people that find such a fixed media area that does not change (with the same way of being called upon over more than one project). Of course, as stated, that may be just because I have not seen the light just yet. Thanks for all the responses though, I will ponder my alternatives, but guess I will stick with the image asset folder and make sure it is not changed!
-
Because, to me, it is nice to quickly asses what site specific graphical content I have created for a project; and to be able to easily manage and change that content on the server without having to access it with ftp (and make do without clear graphical representation of images and such). The longer since I actually did the work on the site - the happier I will probably be to have that quick easy access overview when I go back to manage/edit it. To me, that is part of the reason I wanted a CMS.